# Status bar

> The bottom bar: diagnostics, cursor position, language. A native Pyzed component for Python desktop GUIs, with a live preview, code examples and its API.

Source: https://albakore.github.io/pyzed/library/status-bar/

:::tip[In plain words]
The thin bar at the bottom of the window with small facts: errors, line number, language.
:::

The bottom bar with items at the `start` and `end`. `ui.status_item` shows an icon and/or text, can be pressed, `selected` (a dock that is open) and carry a `tooltip` with `keys`.

`ui.status_bar` · Category: [Workspace](https://albakore.github.io/pyzed/library/#workspace) · [Full reference →](https://albakore.github.io/pyzed/reference/ui/#status_bar)

**Code:**

```python
ui.status_bar(
    [ui.status_item(icon="panel-left", on_press=on_toggle, selected=True, tooltip="Project panel", keys="ctrl-b"),
     ui.status_item("0", icon="circle-x"), ui.status_item("2", icon="triangle-alert", icon_color="warning")],
    [ui.status_item("Ln 12, Col 8"), ui.status_item("UTF-8"), ui.status_item("Python", icon="file-code")],
)
```

## When to use

- For always-visible state: errors and warnings, cursor position, language, git branch.

## Usage

```python
from pyzed import ui

ui.status_bar(
    [ui.status_item(icon="panel-left", on_press=on_toggle, selected=True, tooltip="Project panel", keys="ctrl-b"),
     ui.status_item("0", icon="circle-x"), ui.status_item("2", icon="triangle-alert", icon_color="warning")],
    [ui.status_item("Ln 12, Col 8"), ui.status_item("UTF-8"), ui.status_item("Python", icon="file-code")],
)
```

## 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.
:::

### Items

```python
ui.status_item("Ln 12, Col 8")
```

```python
ui.status_item("Python", icon="file-code")
```

```python
ui.status_item("2", icon="triangle-alert", icon_color="warning")
```

```python
ui.status_item(icon="panel-left", on_press=on_toggle, selected=True)
```

```python
ui.status_item("main", icon="git-branch", color="accent")
```

### Bar

```python
pz.container(ui.status_bar([ui.status_item("0", icon="circle-x")],
                           [ui.status_item("UTF-8"), ui.status_item("Python")]), width=420)
```

## Events

Status bar has **1 event of its own**, listed below. 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/).

| Event | Handler gets | When |
| --- | --- | --- |
| `on_press` | `()` | Message or callable sent on press. `None` disables the control. |

**Handler gets** is what Pyzed passes to your callable: `()` means nothing. Any handler can also be a message (a value that is not callable), which goes to `update()`.

### Handling the events

The same events written three ways. **Imperative**: methods of the app change `self`. **Declarative**: the handlers produce messages and one `update()` decides. **Functional**: a pure function draws an immutable state and asks for changes with `set_state(...)`. See [Imperative, declarative and functional](https://albakore.github.io/pyzed/guides/code-styles/).

**Imperative:**

```python
class Ide(pz.App):
    def __init__(self):
        self.show_left = True

    def view(self):
        return ui.status_bar(
            [ui.status_item(icon="panel-left", selected=self.show_left, tooltip="Project panel",
                            on_press=lambda: setattr(self, "show_left", not self.show_left))],
            [ui.status_item("Python", icon="file-code")],
        )
```

**Declarative:**

```python
class Ide(pz.App):
    show_left = True

    def update(self, message):
        if message == "toggle left":
            self.show_left = not self.show_left

    def view(self):
        return ui.status_bar([ui.status_item(icon="panel-left", on_press="toggle left",
                                             selected=self.show_left)])
```

**Functional:**

```python
from dataclasses import dataclass

@dataclass(frozen=True)
class State:
    show_left: bool = True

def view(state, set_state):
    return ui.status_bar([ui.status_item(icon="panel-left", selected=state.show_left,
                                         on_press=lambda: set_state(show_left=not state.show_left))])
```

## Properties and API

### `ui.status_bar`

```python
status_bar(start=(), end=(), *, height=28, theme=None)
```

The bottom status bar.

| Property | Default | Description |
| --- | --- | --- |
| `start` | `()` | Widgets at the start (left). |
| `end` | `()` | Widgets at the end (right). |
| `height` | `28` | Height. |
| `theme` | `None` | Theme to use instead of the current one (`pyzed.theme.current()`). |

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

### `ui.status_item`

```python
status_item(
    content=None,
    on_press=None,
    *,
    icon=None,
    color=None,
    icon_color=None,
    selected=False,
    tooltip=None,
    keys=None,
    theme=None,
)
```

An icon and/or text in the status bar (diagnostics, cursor position, language…).

| Property | Default | Description |
| --- | --- | --- |
| `content` | `None` | Text. |
| `icon` | `None` | Name of a Lucide icon (`pyzed icons` lists them). |
| `color` | `None` | Text or icon color. |
| `icon_color` | `None` | Icon color: a theme token or a hex color. |
| `selected` | `False` | Marks it as selected. |
| `tooltip` | `None` | Tooltip text. |
| `keys` | `None` | Shortcut shown at the end, written as a string: `"ctrl-s"`, `"cmd-k cmd-s"`. |
| `theme` | `None` | Theme to use instead of the current one (`pyzed.theme.current()`). |

Events: `on_press` ([events](#events)).

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

## Related

- [Workspace](https://albakore.github.io/pyzed/library/workspace/): The layout of an editor-style window: title bar, docks, center, status bar.
- [Title bar](https://albakore.github.io/pyzed/library/title-bar/): The top bar with project and branch pickers.
- [Count badge](https://albakore.github.io/pyzed/library/count-badge/): A round counter that shows 99+ above its max.
