# Toolbar

A row or column of controls that takes one stop in the Tab order and moves focus with the arrow keys.

- Page: https://www.effectcn.com/components/toolbar
- Kind: Headless component with parts
- File: `src/ui/toolbar.ts`
- Built on: `Toolbar` from `@effect/ui-kit`

## Installation

1. Set up the project once: the packages, Tailwind CSS, the theme tokens and the `cn` helper. See [Installation](https://www.effectcn.com/docs/installation.md).
2. Copy the file below to `src/ui/toolbar.ts`. The kit owns behaviour, ARIA and data attributes. This file is the look, written with Tailwind classes, and it is yours to change.
3. Import it.

`src/ui/toolbar.ts`

```ts
import type { Component } from "@effect/ui"
import type { Html } from "@effect/ui/html"
import type { ButtonElement, Toolbar } from "@effect/ui-kit"
import { cn } from "#lib/cn"

type ToolbarParts = Component.Headless.Parts<typeof Toolbar>

interface ClassOption {
  readonly class?: string | undefined
}

const control =
  "inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-sm border-0 bg-transparent text-[13px] font-medium " +
  "whitespace-nowrap text-foreground no-underline select-none transition-colors duration-150 " +
  "hover:bg-accent hover:text-accent-foreground focus-visible:outline-offset-0 " +
  "[&_svg]:size-4 [&_svg]:shrink-0"

const buttonSizes = {
  icon: "w-8 px-0",
  text: "px-2.5"
} as const

export type ToolbarButtonSize = keyof typeof buttonSizes

/** The bar. The kit sets `data-orientation`, and a vertical toolbar becomes a column. */
export const ToolbarRoot = <Msg>(
  h: Html.H<Msg>,
  toolbar: Pick<ToolbarParts, "root">,
  options: ClassOption & { readonly label: string }
) =>
  toolbar.root(
    h.div
      .class(cn(
        "group/toolbar inline-flex items-center gap-1 rounded-lg border bg-background p-1 shadow-sm",
        "data-[orientation=vertical]:flex-col",
        options.class
      ))
      .attr("aria-label", options.label)
  )

/**
 * One button of the toolbar. To stack it on another kit part, pass that part as
 * `element`: a toggle group's item, `toggleGroup.item({ element: h.button, value })`,
 * which fills with the brand colour while pressed, or a menu's trigger.
 */
export const ToolbarButton = <Msg>(
  h: Html.H<Msg>,
  toolbar: Pick<ToolbarParts, "button">,
  options: ClassOption & {
    readonly value: string
    readonly size?: ToolbarButtonSize | undefined
    readonly label?: string | undefined
    readonly element?: ButtonElement<Msg> | undefined
  }
) =>
  toolbar.button({
    element: (options.element ?? h.button)
      .class(cn(
        control,
        "group data-[disabled]:pointer-events-none data-[disabled]:opacity-45 data-[focusable]:pointer-events-auto",
        "data-[focusable]:data-[disabled]:cursor-not-allowed data-[focusable]:data-[disabled]:hover:bg-transparent",
        "data-[pressed]:bg-brand data-[pressed]:text-brand-foreground",
        "data-[popup-open]:bg-accent",
        buttonSizes[options.size ?? "icon"],
        options.class
      ))
      .attr("aria-label", options.label),
    value: options.value
  })

/** A link among the toolbar's items. Chain `target` and `rel` on the result. */
export const ToolbarLink = <Msg>(
  h: Html.H<Msg>,
  toolbar: Pick<ToolbarParts, "link">,
  options: ClassOption & { readonly value: string; readonly href: string }
) =>
  toolbar.link({
    element: h.a
      .class(cn(control, "px-2.5 font-normal text-muted-foreground", options.class))
      .attr("href", options.href),
    value: options.value
  })

/** A text input, which goes last in a horizontal toolbar. Chain `.value(...)` and the `input` handler on the result. */
export const ToolbarInput = <Msg>(
  h: Html.H<Msg>,
  toolbar: Pick<ToolbarParts, "input">,
  options: ClassOption & {
    readonly value: string
    readonly type?: string | undefined
    readonly placeholder?: string | undefined
    readonly label?: string | undefined
  }
) =>
  toolbar.input({
    element: h.input
      .class(cn(
        "h-8 w-44 rounded-sm border border-input bg-background px-2.5 text-[13px] text-foreground outline-none",
        "transition-colors duration-150 placeholder:text-muted-foreground focus-visible:border-ring",
        "data-[disabled]:opacity-50",
        options.class
      ))
      .attrs({
        type: options.type ?? "text",
        placeholder: options.placeholder,
        "aria-label": options.label ?? options.placeholder
      }),
    value: options.value
  })

/** A group of items that can be disabled together, by its entry in the `groups` prop. */
export const ToolbarGroup = <Msg>(
  h: Html.H<Msg>,
  toolbar: Pick<ToolbarParts, "group">,
  options: ClassOption & { readonly value: string; readonly label?: string | undefined }
) =>
  toolbar.group({
    element: h.div
      .class(cn("flex items-center gap-0.5 data-[orientation=vertical]:flex-col", options.class))
      .attr("aria-label", options.label),
    value: options.value
  })

/** A line between items, across the toolbar's direction. */
export const ToolbarSeparator = <Msg>(h: Html.H<Msg>, toolbar: Pick<ToolbarParts, "separator">, options: ClassOption = {}) =>
  toolbar.separator(
    h.div.class(cn(
      "shrink-0 bg-border data-[orientation=horizontal]:my-0.5 data-[orientation=horizontal]:h-px",
      "data-[orientation=horizontal]:w-6 data-[orientation=vertical]:mx-0.5 data-[orientation=vertical]:h-5",
      "data-[orientation=vertical]:w-px",
      options.class
    ))
  )
```

```ts
import { ToolbarRoot, ToolbarButton, ToolbarLink, ToolbarInput, ToolbarGroup, ToolbarSeparator } from "#ui/toolbar"
```

## Usage

Two toggle groups and two buttons share one tab stop. Each toggle item is stacked inside a toolbar button.

```ts
import { UiSchema } from "@effect/ui"
import { Html } from "@effect/ui/html"
import { Button, ToggleGroup, Toolbar } from "@effect/ui-kit"
import { Schema } from "effect"
import { ToolbarButton, ToolbarRoot, ToolbarSeparator } from "#ui/toolbar"

const ToolbarEditorMessage = UiSchema.TaggedEnum({
  ToggledMarks: { value: Schema.Array(Schema.String) },
  ToggledAlign: { value: Schema.Array(Schema.String) },
  PressedUndo: {},
  PressedRedo: {}
})

const marks = [
  { value: "bold", label: "Bold", glyph: "B" },
  { value: "italic", label: "Italic", glyph: "I" },
  { value: "underline", label: "Underline", glyph: "U" }
]

const alignments = [
  { value: "left", label: "Align left", icon: "M4 6h16M4 12h10M4 18h13" },
  { value: "center", label: "Align center", icon: "M4 6h16M7 12h10M5 18h14" },
  { value: "right", label: "Align right", icon: "M4 6h16M10 12h10M7 18h13" }
]

const items = [...marks, ...alignments, { value: "undo" }, { value: "redo" }].map(({ value }) => ({ value }))

export const ToolbarEditor = Html.component({
  name: "ToolbarEditor",
  model: Schema.Struct({
    marks: Schema.Array(Schema.String),
    align: Schema.String,
    edits: Schema.Number
  }),
  message: ToolbarEditorMessage
}).make({
  init: () => ({ marks: ["bold"], align: "left", edits: 3 }),
  update: {
    ToggledMarks: ($, { value }) => $.evolve({ marks: value, edits: (edits) => edits + 1 }),
    // One alignment always stays pressed.
    ToggledAlign: ($, { value }) => value[0] === undefined ? $.model : $.evolve({ align: value[0] }),
    PressedUndo: ($) => $.evolve({ edits: (edits) => Math.max(0, edits - 1) }),
    PressedRedo: ($) => $.evolve({ edits: (edits) => edits + 1 })
  },
  view: (h, model) => {
    const icon = (d: string) =>
      h.el("svg")
        .attrs({ viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "aria-hidden": "true" })
        .children(h.el("path").attrs({ d, "stroke-linecap": "round", "stroke-linejoin": "round" }))
    return h.div.class("flex flex-col items-center gap-4").children(
      Toolbar(h, {
        props: { items },
        view: (toolbar) =>
          ToolbarRoot(h, toolbar, { label: "Formatting" }).children(
            ToggleGroup(h, {
              key: "marks",
              props: { value: model.marks, items: marks.map(({ value }) => ({ value })), multiple: true },
              onEmit: ({ value }) => ToolbarEditorMessage.ToggledMarks({ value }),
              view: (toggleGroup) =>
                toggleGroup.root(h.div.class("flex items-center gap-0.5").attr("aria-label", "Text style")).children(
                  marks.map(({ glyph, label, value }) =>
                    // Stack the toolbar's button on the toggle group's item, with one value.
                    ToolbarButton(h, toolbar, {
                      value,
                      label,
                      class: "font-serif text-[15px]",
                      element: toggleGroup.item({ element: h.button, value })
                    }).children(glyph)
                  )
                )
            }),
            ToolbarSeparator(h, toolbar),
            ToggleGroup(h, {
              key: "align",
              props: { value: [model.align], items: alignments.map(({ value }) => ({ value })) },
              onEmit: ({ value }) => ToolbarEditorMessage.ToggledAlign({ value }),
              view: (toggleGroup) =>
                toggleGroup.root(h.div.class("flex items-center gap-0.5").attr("aria-label", "Alignment")).children(
                  alignments.map(({ icon: d, label, value }) =>
                    ToolbarButton(h, toolbar, { value, label, element: toggleGroup.item({ element: h.button, value }) }).children(icon(d))
                  )
                )
            }),
            ToolbarSeparator(h, toolbar),
            Button(h, {
              element: ToolbarButton(h, toolbar, { value: "undo", label: "Undo" }),
              onPress: ToolbarEditorMessage.PressedUndo()
            }).children(icon("M9 14 4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3")),
            Button(h, {
              element: ToolbarButton(h, toolbar, { value: "redo", label: "Redo" }),
              onPress: ToolbarEditorMessage.PressedRedo()
            }).children(icon("m15 14 5-5-5-5M20 9H10a6 6 0 0 0 0 12h3"))
          )
      }),
      h.p.class("text-xs text-muted-foreground tabular-nums").children(
        `${model.marks.length === 0 ? "Plain" : model.marks.join(" + ")}, aligned ${model.align}, ${model.edits} edits`
      )
    )
  }
})
```

## Examples

### With a menu

A Menu trigger is a toolbar button too. Buttons that reach their limit are disabled but stay focusable.

```ts
import { UiSchema } from "@effect/ui"
import { Html } from "@effect/ui/html"
import { Button, Menu, Toolbar } from "@effect/ui-kit"
import { Schema } from "effect"
import { MenuChevron, MenuPopup, MenuPositioner, MenuRadioGroup, MenuRadioItem } from "#ui/menu"
import { ToolbarButton, ToolbarRoot, ToolbarSeparator } from "#ui/toolbar"

const ToolbarMenuMessage = UiSchema.TaggedEnum({
  RequestedOpenMenu: {},
  RequestedCloseMenu: {},
  PickedStyle: { value: Schema.String },
  PressedSmaller: {},
  PressedLarger: {}
})

const styles = [
  { value: "paragraph", label: "Paragraph" },
  { value: "heading-1", label: "Heading 1" },
  { value: "heading-2", label: "Heading 2" },
  { value: "quote", label: "Quote" },
  { value: "code", label: "Code block" }
]

export const ToolbarMenu = Html.component({
  name: "ToolbarMenu",
  model: Schema.Struct({ open: Schema.Boolean, style: Schema.String, size: Schema.Number }),
  message: ToolbarMenuMessage
}).make({
  init: () => ({ open: false, style: "paragraph", size: 14 }),
  update: {
    RequestedOpenMenu: ($) => $.evolve({ open: true }),
    RequestedCloseMenu: ($) => $.evolve({ open: false }),
    PickedStyle: ($, { value }) => $.evolve({ style: value }),
    PressedSmaller: ($) => $.evolve({ size: (size) => Math.max(10, size - 1) }),
    PressedLarger: ($) => $.evolve({ size: (size) => Math.min(24, size + 1) })
  },
  view: (h, model) =>
    Toolbar(h, {
      props: {
        items: [
          { value: "style" },
          { value: "smaller", disabled: model.size === 10 },
          { value: "larger", disabled: model.size === 24 }
        ]
      },
      view: (toolbar) =>
        ToolbarRoot(h, toolbar, { label: "Text" }).children(
          Menu(h, {
            // A trigger handles clicks on its own layer, so it takes the item's disabled state too.
            props: { open: model.open, items: styles, disabled: toolbar.isDisabled("style"), align: "start", sideOffset: 8 },
            onEmit: {
              RequestedOpen: () => ToolbarMenuMessage.RequestedOpenMenu(),
              RequestedClose: () => ToolbarMenuMessage.RequestedCloseMenu(),
              Picked: ({ value }) => ToolbarMenuMessage.PickedStyle({ value }),
              Highlighted: () => undefined,
              RequestedQuery: () => undefined,
              Settled: () => undefined
            },
            view: (menu) =>
              h.div.children(
                ToolbarButton(h, toolbar, { value: "style", size: "text", element: menu.trigger({ element: h.button }) })
                  .children(styles.find((style) => style.value === model.style)?.label, MenuChevron(h)),
                MenuPositioner(h, menu).children(
                  MenuPopup(h, menu).children(
                    MenuRadioGroup(h, menu, { value: model.style, label: "Text style" }).children(
                      styles.map(({ label, value }) =>
                        MenuRadioItem(h, menu, { value, closeOnClick: true }).children(label)
                      )
                    )
                  )
                )
              )
          }),
          ToolbarSeparator(h, toolbar),
          Button(h, {
            element: ToolbarButton(h, toolbar, { value: "smaller", label: "Smaller text" }),
            onPress: ToolbarMenuMessage.PressedSmaller()
          }).children("A−"),
          h.span.class("w-10 text-center text-xs text-muted-foreground tabular-nums").children(`${model.size}px`),
          Button(h, {
            element: ToolbarButton(h, toolbar, { value: "larger", label: "Larger text" }),
            onPress: ToolbarMenuMessage.PressedLarger()
          }).children("A+")
        )
    })
})
```

### Vertical

A tool palette. ArrowDown and ArrowUp move through the tools and the zoom buttons.

```ts
import { UiSchema } from "@effect/ui"
import { Html } from "@effect/ui/html"
import { Button, ToggleGroup, Toolbar } from "@effect/ui-kit"
import { Schema } from "effect"
import { ToolbarButton, ToolbarRoot, ToolbarSeparator } from "#ui/toolbar"

const ToolbarVerticalMessage = UiSchema.TaggedEnum({
  ToggledTool: { value: Schema.Array(Schema.String) },
  PressedZoomIn: {},
  PressedZoomOut: {}
})

const tools = [
  { value: "select", label: "Select", icon: "m5 3 14 8-6 2-2 6Z" },
  { value: "pen", label: "Pen", icon: "M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z" },
  { value: "rectangle", label: "Rectangle", icon: "M4 5h16v14H4z" },
  { value: "text", label: "Text", icon: "M5 6V4h14v2M12 4v16M9 20h6" }
]

export const ToolbarVertical = Html.component({
  name: "ToolbarVertical",
  model: Schema.Struct({ tool: Schema.String, zoom: Schema.Number }),
  message: ToolbarVerticalMessage
}).make({
  init: () => ({ tool: "select", zoom: 100 }),
  update: {
    ToggledTool: ($, { value }) => value[0] === undefined ? $.model : $.evolve({ tool: value[0] }),
    PressedZoomIn: ($) => $.evolve({ zoom: (zoom) => Math.min(400, zoom * 2) }),
    PressedZoomOut: ($) => $.evolve({ zoom: (zoom) => Math.max(25, zoom / 2) })
  },
  view: (h, model) => {
    const icon = (d: string) =>
      h.el("svg")
        .attrs({ viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "aria-hidden": "true" })
        .children(h.el("path").attrs({ d, "stroke-linecap": "round", "stroke-linejoin": "round" }))
    return h.div.class("flex items-center gap-6").children(
      Toolbar(h, {
        props: {
          orientation: "vertical",
          items: [...tools.map(({ value }) => ({ value })), { value: "zoom-in" }, { value: "zoom-out" }]
        },
        view: (toolbar) =>
          ToolbarRoot(h, toolbar, { label: "Tools" }).children(
            ToggleGroup(h, {
              props: { value: [model.tool], items: tools.map(({ value }) => ({ value })), orientation: "vertical" },
              onEmit: ({ value }) => ToolbarVerticalMessage.ToggledTool({ value }),
              view: (toggleGroup) =>
                toggleGroup.root(h.div.class("flex flex-col gap-0.5").attr("aria-label", "Tool")).children(
                  tools.map(({ icon: d, label, value }) =>
                    ToolbarButton(h, toolbar, { value, label, element: toggleGroup.item({ element: h.button, value }) }).children(icon(d))
                  )
                )
            }),
            ToolbarSeparator(h, toolbar),
            Button(h, {
              element: ToolbarButton(h, toolbar, { value: "zoom-in", label: "Zoom in" }),
              onPress: ToolbarVerticalMessage.PressedZoomIn()
            }).children(icon("M12 5v14M5 12h14")),
            Button(h, {
              element: ToolbarButton(h, toolbar, { value: "zoom-out", label: "Zoom out" }),
              onPress: ToolbarVerticalMessage.PressedZoomOut()
            }).children(icon("M5 12h14"))
          )
      }),
      h.p.class("text-xs text-muted-foreground tabular-nums").children(`${model.tool} tool at ${model.zoom}%`)
    )
  }
})
```

### Links and an input

Links and a search input are items as well. In the input the arrow keys move the caret and leave only from its ends.

```ts
import { UiSchema } from "@effect/ui"
import { Html } from "@effect/ui/html"
import { Button, Toolbar } from "@effect/ui-kit"
import { Schema } from "effect"
import { ToolbarButton, ToolbarInput, ToolbarLink, ToolbarRoot, ToolbarSeparator } from "#ui/toolbar"

const ToolbarLinksInputMessage = UiSchema.TaggedEnum({
  PressedNew: {},
  UpdatedSearch: { value: Schema.String }
})

export const ToolbarLinksInput = Html.component({
  name: "ToolbarLinksInput",
  model: Schema.Struct({ search: Schema.String, created: Schema.Number }),
  message: ToolbarLinksInputMessage
}).make({
  init: () => ({ search: "", created: 0 }),
  update: {
    PressedNew: ($) => $.evolve({ created: (created) => created + 1 }),
    UpdatedSearch: ($, { value }) => $.evolve({ search: value })
  },
  view: (h, model) =>
    h.div.class("flex flex-col items-center gap-4").children(
      Toolbar(h, {
        props: { items: [{ value: "new" }, { value: "docs" }, { value: "source" }, { value: "search" }] },
        view: (toolbar) =>
          ToolbarRoot(h, toolbar, { label: "Issues" }).children(
            Button(h, {
              element: ToolbarButton(h, toolbar, { value: "new", size: "text" }),
              onPress: ToolbarLinksInputMessage.PressedNew()
            }).children("New issue"),
            ToolbarSeparator(h, toolbar),
            ToolbarLink(h, toolbar, { value: "docs", href: "https://effect.website/docs" })
              .attrs({ target: "_blank", rel: "noreferrer" })
              .children("Docs"),
            ToolbarLink(h, toolbar, { value: "source", href: "https://github.com/Effect-TS/ui" })
              .attrs({ target: "_blank", rel: "noreferrer" })
              .children("Source"),
            // Left and Right also move the caret, so a text input goes last.
            ToolbarInput(h, toolbar, { value: "search", type: "search", placeholder: "Search issues…" })
              .value(model.search)
              .on("input", ({ value }) => ToolbarLinksInputMessage.UpdatedSearch({ value }))
          )
      }),
      h.p.class("text-xs text-muted-foreground tabular-nums").children(
        `${model.created} created` + (model.search === "" ? "" : `, searching for "${model.search}"`)
      )
    )
})
```

### Disabled group

A group disables its items together. Delete opts out of focusableWhenDisabled, so the arrow keys skip it.

```ts
import { UiSchema } from "@effect/ui"
import { Html } from "@effect/ui/html"
import { Button, Toolbar } from "@effect/ui-kit"
import { Schema } from "effect"
import { ToolbarButton, ToolbarGroup, ToolbarRoot, ToolbarSeparator } from "#ui/toolbar"

const ToolbarDisabledMessage = UiSchema.TaggedEnum({
  PressedLock: {},
  PressedAction: { action: Schema.String }
})

const clipboard = [
  { value: "cut", label: "Cut" },
  { value: "copy", label: "Copy" },
  { value: "paste", label: "Paste" }
]

export const ToolbarDisabled = Html.component({
  name: "ToolbarDisabled",
  model: Schema.Struct({ locked: Schema.Boolean, last: Schema.NullOr(Schema.String) }),
  message: ToolbarDisabledMessage
}).make({
  init: () => ({ locked: true, last: null }),
  update: {
    PressedLock: ($) => $.evolve({ locked: (locked) => !locked }),
    PressedAction: ($, { action }) => $.evolve({ last: action })
  },
  view: (h, model) =>
    h.div.class("flex flex-col items-center gap-4").children(
      Toolbar(h, {
        props: {
          // A disabled group disables its items. They stay focusable unless an entry opts out.
          groups: [{ value: "clipboard", disabled: model.locked }],
          items: [
            { value: "lock" },
            ...clipboard.map(({ value }) => ({ value, group: "clipboard" })),
            { value: "delete", disabled: true, focusableWhenDisabled: false }
          ]
        },
        view: (toolbar) =>
          ToolbarRoot(h, toolbar, { label: "Clipboard" }).children(
            Button(h, {
              element: ToolbarButton(h, toolbar, { value: "lock", size: "text" }),
              onPress: ToolbarDisabledMessage.PressedLock()
            }).children(model.locked ? "Unlock" : "Lock"),
            ToolbarSeparator(h, toolbar),
            ToolbarGroup(h, toolbar, { value: "clipboard", label: "Clipboard" })
              .children(
                clipboard.map(({ label, value }) =>
                  Button(h, {
                    element: ToolbarButton(h, toolbar, { value, size: "text" }),
                    onPress: ToolbarDisabledMessage.PressedAction({ action: label })
                  }).children(label)
                )
              ),
            Button(h, {
              element: ToolbarButton(h, toolbar, { value: "delete", size: "text" }),
              onPress: ToolbarDisabledMessage.PressedAction({ action: "Delete" })
            }).children("Delete")
          )
      }),
      h.p.class("text-xs text-muted-foreground tabular-nums").children(
        model.locked ? "Locked: the arrow keys still reach the clipboard buttons" : `Last action: ${model.last ?? "none"}`
      )
    )
})
```

## Anatomy

The parts the `view` closure receives. Apply each one to an element of your own.

| Part | Description |
| --- | --- |
| `root` | The <div> with role="toolbar". |
| `button` | A <button> per button item, { element, value }. Stack it on a toggle group's item or a Menu, Select or Dialog trigger. |
| `link` | An <a> per link item. A link is never disabled. |
| `input` | An <input> per input item. Put at most one in a horizontal toolbar, as its last item. |
| `group` | A <div> around some items, { element, value }, that can disable them together. |
| `separator` | A <div> between items, across the toolbar's direction. |
| `isDisabled(value)` | Whether an item is disabled, for a Menu or Select stacked inside it. |

## API reference

### Props

| Prop | Type | Description |
| --- | --- | --- |
| `items` | `Array<{ value, disabled?, focusableWhenDisabled?, group? }>` | Every button, link and input in the order they are drawn. Required. |
| `groups` | `Array<{ value, disabled? }>` | Every group drawn with the group part. |
| `disabled` | `boolean` | Disables every button and input. |
| `orientation` | `"horizontal" \| "vertical"` | Right and Left move focus by default; "vertical" uses Down and Up. |
| `loopFocus` | `boolean` | The arrow keys wrap from the last item to the first. On by default. |

### Events

| Event | Description |
| --- | --- |
| `(none)` | The toolbar emits nothing: each control inside reports its own press, toggle or choice. |

### Data attributes

| Attribute | Description |
| --- | --- |
| `data-orientation` | On every part. On the separator it is across the toolbar's: "vertical" in a horizontal toolbar. |
| `data-disabled` | On the root, a group, a button or an input that is disabled. |
| `data-focusable` | On a button or input that stays focusable while disabled. |
| `data-pressed` | On a toggle group item stacked on a toolbar button. |

## Related components

- [Menu](https://www.effectcn.com/components/menu.md): A button that opens a list of actions, links, checkbox and radio items, and submenus.
