# Divider

> A thin line in the theme's border color. A native Pyzed component for Python desktop GUIs, with a live preview, code examples and its API.

Source: https://albakore.github.io/pyzed/library/divider/

:::tip[In plain words]
A thin line that separates groups of things.
:::

A one-pixel line in the theme's border color, horizontal by default (`vertical=True` for a vertical one). `pz.rule` is the base version with your own `color` and `thickness`.

`ui.divider` · Category: [Display](https://albakore.github.io/pyzed/library/#display) · [Full reference →](https://albakore.github.io/pyzed/reference/ui/#divider)

**Code:**

```python
pz.column([
    ui.label("Account"),
    ui.divider(),
    pz.row([ui.label("Edit"), ui.divider(vertical=True), ui.label("View"),
            ui.divider(vertical=True), ui.label("Help")], spacing=12, height=20),
    ui.divider(),
    ui.muted("Sign out"),
], spacing=10, width=300)
```

## When to use

- To separate groups in a column or items in a toolbar.
- Prefer spacing first; add a divider when groups really need a visual break.

## Usage

```python
import pyzed as pz
from pyzed import ui

pz.column([
    ui.label("Account"),
    ui.divider(),
    pz.row([ui.label("Edit"), ui.divider(vertical=True), ui.label("View"),
            ui.divider(vertical=True), ui.label("Help")], spacing=12, height=20),
    ui.divider(),
    ui.muted("Sign out"),
], spacing=10, width=300)
```

## Variants

:::note[About these captures]
Each capture is recorded by pyzed itself, off-screen at 2x, in One Dark or One Light to match this site's theme, and cropped to the component so it shows at its real size. The pointer hovers, presses or types into it; a component that does not react to the pointer cycles through a few themes. With reduced motion you see the first frame. Open **Code** under a capture to see the snippet that draws it; free names such as `on_save` stand for your own callbacks.
:::

### Direction

```python
pz.column([ui.label("Account"), ui.divider(), ui.label("Sign out")], spacing=8, width=220)
```

```python
pz.row([ui.label("Edit"), ui.divider(vertical=True), ui.label("View")], spacing=10, height=18)
```

### Color

```python
pz.container(ui.divider(color="accent"), width=220)
```

```python
pz.container(pz.rule(color="#e5c07b", thickness=3), width=220)
```

### States and events

```python
pz.container(ui.divider(label="or"), width=300)
```

```python
pz.column([ui.label("Above"), ui.divider(spacing=12), ui.label("Below")], width=300)
```

## Events

Divider has no events of its own: it shows what you give it. Like every widget it also has the **18 common events** (`click`, `double_click`, `right_click`, `mouse_enter`, `drag`, `key_down`, `resize`…), attached with `.on(...)`: see [Events](https://albakore.github.io/pyzed/guides/events/) and [Events of every component](https://albakore.github.io/pyzed/library/events/).

## Properties and API

### `ui.divider`

```python
divider(*, vertical=False, color=None, label=None, spacing=0, theme=None)
```

A divider line in the theme color.

| Property | Default | Description |
| --- | --- | --- |
| `vertical` | `False` | Vertical instead of horizontal. |
| `color` | `None` | Text or icon color. |
| `label` | `None` | Muted text in the middle of a horizontal line (`"or"`, a date…). |
| `spacing` | `0` | Space on both sides of the line. |
| `theme` | `None` | Theme to use instead of the current one (`pyzed.theme.current()`). |

[Full reference →](https://albakore.github.io/pyzed/reference/ui/#divider)

### `pz.rule`

```python
rule(*, vertical=False, thickness=1.0, color=None)
```

A horizontal (or vertical) divider line.

| Property | Default | Description |
| --- | --- | --- |
| `vertical` | `False` | Vertical line instead of horizontal. |
| `thickness` | `1.0` | Thickness in pixels. |
| `color` | `None` | Text or icon color. |

[Full reference →](https://albakore.github.io/pyzed/reference/widgets/#rule)

## Related

- [Card](https://albakore.github.io/pyzed/library/card/): A bordered surface with an optional title and actions.
- [Toolbar](https://albakore.github.io/pyzed/library/toolbar/): The bar under the tabs: breadcrumbs and buffer actions.
