# Toolbar

Arrow-key navigation across a group of commands. (Custom element.)

Reference: https://timeless.build/docs/components/toolbar/

## Markup

```html
<ui-toolbar aria-label="Formatting">
  <button class="ui-button" data-ui-variant="ghost" type="button">Bold</button>
  <button class="ui-button" data-ui-variant="ghost" type="button">Italic</button>
  <button class="ui-button" data-ui-variant="ghost" type="button">Underline</button>
  <button class="ui-button" data-ui-variant="ghost" type="button" disabled>Comment</button>
</ui-toolbar>
```

## Install

```js
import '@timelessui/components/css/tokens.css'
import '@timelessui/components/css/core/toolbar.css'
import '@timelessui/components/css/core/button.css'
import '@timelessui/components/css/themes/atmosphere/tokens.css'
import '@timelessui/components/css/themes/atmosphere/button.css'
import '@timelessui/components/css/themes/atmosphere/toolbar.css'
import '@timelessui/components/register/ui-toolbar'
```

A `register/` import is a side effect: it defines the element as the module evaluates, so it
has to run in code the browser loads. To register explicitly instead — to control the timing,
or to define into another window — call the function from the matching `define/` entry point,
which registers nothing on its own:

```js
import { defineToolbarElement } from '@timelessui/components/define/ui-toolbar'
defineToolbarElement()
```

## Anatomy

Parts are authored in your own markup and identified by the selector below. Required parts
must be present for the component to work. Private `data-ui-internal-*` hooks are written by
the runtime and must never be authored.

| Part | Required | Selector | Purpose |
| --- | --- | --- | --- |
| `item` | Yes | `button, a, input, select, textarea` | Any focusable control in the toolbar. Timeless makes the group one tab stop and moves focus with the arrow keys. |

## Attributes

Every value below is implemented by the stylesheets this component ships. Boolean attributes
are presence-based: author the attribute with no value, or omit it.

| Attribute | Values | Default | Description |
| --- | --- | --- | --- |
| `orientation` | `horizontal` · `vertical` | `horizontal` | Arrow-key axis across the toolbar controls. |

## Element API

Attributes above are the authoring surface. These are the DOM properties and events the
registered element adds once it upgrades.

### `<ui-toolbar>`

| Property | Type | Notes |
| --- | --- | --- |
| `orientation` | `'horizontal' | 'vertical'` | Reflects the `orientation` attribute |

This element dispatches no component events.

## Styling

Root identity: `ui-toolbar`.
Required stylesheets: `tokens.css`, `core/toolbar.css`, `core/button.css`, `themes/atmosphere/tokens.css`, `themes/atmosphere/button.css`, `themes/atmosphere/toolbar.css`.

This component adds no custom properties of its own. Restyle it through the design tokens at https://timeless.build/docs/styling/theming/ or your own CSS.

Design tokens this component reads (22), global and set at the theme level: `--ui-accent`, `--ui-bg-accent`, `--ui-bg-accent-active`, `--ui-bg-accent-hover`, `--ui-bg-control`, `--ui-bg-control-active`, `--ui-bg-control-hover`, `--ui-bg-control-muted`, `--ui-bg-danger`, `--ui-bg-danger-active`, `--ui-bg-danger-hover`, `--ui-duration-fast`, `--ui-ease-standard`, `--ui-fg`, `--ui-focus`, `--ui-radius-control`, `--ui-radius-md`, `--ui-shadow-control-accent`, `--ui-shadow-control-active`, `--ui-shadow-control-danger`, `--ui-shadow-outline-control`, `--ui-space-1`.

## Accessibility

Keep the native elements, roles, and relationships shown in the markup. Timeless adds only the
state and keyboard coordination the platform does not already provide, and it never supplies
your accessible names — those depend on your content.

Follows the [Toolbar pattern](https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/) from the ARIA Authoring Practices Guide.

| Key | Action |
| --- | --- |
| `Arrow keys` | Move focus to the previous or next control, following the orientation and skipping disabled ones. |
| `Home / End` | Move focus to the first or last enabled control. |

The whole toolbar is one tab stop. Timeless manages roving `tabindex` so Tab moves past the group rather than through every control. A toolbar control is a real control rather than a command, so `disabled` is the right spelling here and the arrows skip it — unlike [Menu](/docs/components/menu/), where `aria-disabled` keeps an unavailable command discoverable. Give the host an accessible name; a toolbar without one is indistinguishable from any other.

## Before JavaScript runs

The markup above is complete and usable on its own: native controls submit, labels associate, and authored ARIA is already correct. Registration adds state synchronisation, focus management, and keyboard coordination on top of it.
