# Bar Items

Extensions can add icons to the top bar, the rail, and the status bar.
Clicking one runs one of the extension's [commands](commands.md).

```json
"topbarItems": [
  { "id": "hello", "icon": "sparkles", "command": "toggle", "tooltip": "Hello" }
],
"railItems": [
  { "id": "notes", "icon": "note.text", "command": "toggle-notes", "tooltip": "Notes" }
],
"statusBarItems": [
  { "id": "count", "icon": "bolt", "text": "0", "side": "right", "command": "show-status" }
]
```

| Field | Notes |
| --- | --- |
| `id`, `icon`, `command` | Required. `icon` follows the [icon format](manifest.md#icons). |
| `tooltip` | Shown on hover. |
| `visible` | Default `true`. |
| `side` | Status bar only, required: `left` or `right`. |
| `text` | Status bar only: text next to the icon. |

Items appear grouped by extension, in manifest order. An item whose command
opens a popover anchors the popover to itself; see [Popovers](panels.md#popovers).

## The rail

The rail is a column of icons on the right edge of the window, below the top
bar. Put an item there instead of the top bar when it opens something the user
returns to, such as a panel, so the top bar stays short.

- The rail starts collapsed. A button at the end of the top bar opens and
  closes it, and Muxy remembers the choice. The button shows only while some
  extension has a visible rail item.
- A popover opened from the rail appears to the left of its icon.
- Users can turn the rail off in **Settings → Appearance → Show rail**. Rail
  items then sit in the top bar, after the extension's top bar items.

## Changing items at runtime

With `panels:write`, pages, scripts, and background scripts can change an item
they declared:

```js
muxy.statusbar.set({ id: "count", text: "3", icon: "bolt.fill" });
muxy.topbar.hide("hello");
muxy.topbar.show("hello");
muxy.rail.set({ id: "notes", icon: "note.text.badge.plus" });
```

`muxy.rail` works like `muxy.topbar`, for rail items. `set` takes `id` plus
any of `icon`, `visible`, and, for the status bar, `text` (`null` clears it). Changes are not saved; items start from the
manifest again after a restart.
