# Toolbar

给按钮、切换按钮、菜单和字段一个 Tab 停靠点，并用方向键导航。

用 Toolbar 把编辑器、画布或表格的控件归成一组。Tab 只进入它一次，方向键在它的按钮、切换按钮、菜单和字段之间移动。

```vue title="demo.vue"
<script setup lang="ts">
import { BoldIcon, ItalicIcon, LinkIcon, UnderlineIcon } from "@lucide/vue"
import { Toggle, ToggleIcon } from "@ui-sdk/vue/toggle"
import { Toolbar, ToolbarButton, ToolbarSeparator } from "@ui-sdk/vue/toolbar"
import { useLog } from "./log"

const styles = [
  { label: "Bold", icon: BoldIcon },
  { label: "Italic", icon: ItalicIcon },
  { label: "Underline", icon: UnderlineIcon },
]

const log = useLog()
</script>

<template>
  <Toolbar aria-label="Formatting">
    <Toggle
      v-for="style in styles"
      :key="style.label"
      :aria-label="style.label"
      @pressed-change="
        (pressed) => log(`${style.label} ${pressed ? 'on' : 'off'}`)
      "
    >
      <ToggleIcon>
        <component :is="style.icon" />
      </ToggleIcon>
    </Toggle>
    <ToolbarSeparator />
    <ToolbarButton aria-label="Insert link" @click="log('Insert link')">
      <LinkIcon aria-hidden="true" />
    </ToolbarButton>
  </Toolbar>
</template>
```

用 Tab 进入工具栏，然后用左、右方向键在 Bold、Italic、Underline 和 Insert link 之间移动。按 Space 切换获得焦点的样式。控制台会记录每次变更。

## 安装
```bash
npm install @ui-sdk/vue @ui-sdk/core
```

## 组合
用下面的组合构建 `Toolbar`：

```text
Toolbar
├── ToolbarButton
├── ToolbarSeparator
├── ToolbarGroup
│   ├── ToolbarButton
│   └── ToolbarButton
├── ToolbarLink
└── ToolbarInput
```

把按钮、链接和字段直接放进工具栏。`ToolbarGroup` 为一组相关的条目命名，`ToolbarSeparator` 在组之间画一条线。切换按钮和切换按钮组自己加入工具栏，菜单和 Select 的触发器则通过 `ToolbarButton` 加入。

## 用法
导入部件并把它们组合起来：

```vue
<script setup lang="ts">
import { Toolbar, ToolbarButton, ToolbarSeparator } from "@ui-sdk/vue/toolbar"
</script>

<template>
  <Toolbar aria-label="Formatting">
    <ToolbarButton>Undo</ToolbarButton>
    <ToolbarButton>Redo</ToolbarButton>
    <ToolbarSeparator />
    <ToolbarButton>Insert Link</ToolbarButton>
  </Toolbar>
</template>
```

用 `aria-label` 给工具栏命名，每个只有图标的控件也要有自己的 `aria-label`。

## 切换按钮组
工具栏里的 [Toggle](/docs/vue/components/toggle) 组会加入它的导航，而不是多出一个 Tab 停靠点。方向键只移动焦点，不按压任何东西；Enter 或 Space 按压获得焦点的切换按钮。

```vue title="toggle-group.vue"
<script setup lang="ts">
import {
  AlignCenterIcon,
  AlignLeftIcon,
  AlignRightIcon,
  ListIcon,
  ListOrderedIcon,
} from "@lucide/vue"
import { Toggle, ToggleGroup, ToggleIcon } from "@ui-sdk/vue/toggle"
import { Toolbar, ToolbarSeparator } from "@ui-sdk/vue/toolbar"
import { useLog } from "./log"

const alignments = [
  { value: "left", label: "Align left", icon: AlignLeftIcon },
  { value: "center", label: "Align center", icon: AlignCenterIcon },
  { value: "right", label: "Align right", icon: AlignRightIcon },
]

const lists = [
  { value: "bulleted", label: "Bulleted list", icon: ListIcon },
  { value: "numbered", label: "Numbered list", icon: ListOrderedIcon },
]

const log = useLog()
</script>

<template>
  <Toolbar aria-label="Paragraph">
    <ToggleGroup
      :default-value="['left']"
      :deselectable="false"
      aria-label="Alignment"
      @value-change="([value]) => log(`Align ${value}`)"
    >
      <Toggle
        v-for="item in alignments"
        :key="item.value"
        :value="item.value"
        :aria-label="item.label"
      >
        <ToggleIcon>
          <component :is="item.icon" />
        </ToggleIcon>
      </Toggle>
    </ToggleGroup>
    <ToolbarSeparator />
    <ToggleGroup
      aria-label="List"
      @value-change="
        ([value]) =>
          log(lists.find((list) => list.value === value)?.label ?? 'No list')
      "
    >
      <Toggle
        v-for="item in lists"
        :key="item.value"
        :value="item.value"
        :aria-label="item.label"
      >
        <ToggleIcon>
          <component :is="item.icon" />
        </ToggleIcon>
      </Toggle>
    </ToggleGroup>
  </Toolbar>
</template>
```

按方向键从对齐分组移到列表分组，然后在 Align center 或 Numbered list 上按 Space。控制台会记录每次选择。

## 分组
用 `ToolbarGroup` 为一组相关的控件命名。在组上设置 `disabled` 可以一起禁用它们；它们保持可聚焦，并带上 `aria-disabled`。

```vue title="group.vue"
<script setup lang="ts">
import {
  ClipboardIcon,
  CopyIcon,
  RedoIcon,
  ScissorsIcon,
  UndoIcon,
} from "@lucide/vue"
import {
  Toolbar,
  ToolbarButton,
  ToolbarGroup,
  ToolbarSeparator,
} from "@ui-sdk/vue/toolbar"
import { useLog } from "./log"

const clipboard = [
  { label: "Cut", icon: ScissorsIcon },
  { label: "Copy", icon: CopyIcon },
  { label: "Paste", icon: ClipboardIcon },
]

const log = useLog()
</script>

<template>
  <Toolbar aria-label="Edit">
    <ToolbarGroup aria-label="Clipboard">
      <ToolbarButton
        v-for="item in clipboard"
        :key="item.label"
        :aria-label="item.label"
        @click="log(item.label)"
      >
        <component :is="item.icon" aria-hidden="true" />
      </ToolbarButton>
    </ToolbarGroup>
    <ToolbarSeparator />
    <ToolbarGroup disabled aria-label="History">
      <ToolbarButton aria-label="Undo">
        <UndoIcon aria-hidden="true" />
      </ToolbarButton>
      <ToolbarButton aria-label="Redo">
        <RedoIcon aria-hidden="true" />
      </ToolbarButton>
    </ToolbarGroup>
  </Toolbar>
</template>
```

用方向键从 Cut、Copy 和 Paste 移到 History。Undo 和 Redo 仍然可以聚焦，但不会做任何事。

## 菜单
通过 `ToolbarButton` 的 `#render` 槽位渲染 [Menu](/docs/vue/components/menu) 触发器。在水平工具栏里，下方向键打开菜单，而左、右方向键继续在工具栏条目之间移动。

```vue
<Menu>
  <ToolbarButton>
    <template #render="{ props }">
      <MenuTrigger v-bind="props">Share</MenuTrigger>
    </template>
  </ToolbarButton>
  <MenuContent>…</MenuContent>
</Menu>
```

```vue title="menu.vue"
<script setup lang="ts">
import { ChevronDownIcon } from "@lucide/vue"
import { Menu, MenuContent, MenuItem, MenuTrigger } from "@ui-sdk/vue/menu"
import { Toolbar, ToolbarButton } from "@ui-sdk/vue/toolbar"
import { useLog } from "./log"

const log = useLog()
</script>

<template>
  <Toolbar aria-label="Document">
    <ToolbarButton @click="log('Saved')">Save</ToolbarButton>
    <Menu @action="(value) => log(`Shared by ${value}`)">
      <ToolbarButton>
        <template #render="{ props }">
          <MenuTrigger v-bind="props">
            Share
            <ChevronDownIcon aria-hidden="true" />
          </MenuTrigger>
        </template>
      </ToolbarButton>
      <MenuContent>
        <MenuItem value="email">Email</MenuItem>
        <MenuItem value="link">Copy Link</MenuItem>
      </MenuContent>
    </Menu>
    <ToolbarButton @click="log('Printed')">Print</ToolbarButton>
  </Toolbar>
</template>
```

聚焦 Share 并按向下方向键，然后选择 Email 或 Copy Link。Escape 关闭菜单并把焦点返回 Share。

## 选择框
[Select](/docs/vue/components/select) 触发器也以同样的方式加入。它参与工具栏的焦点顺序，同时保留自己的选择行为。

```vue title="select.vue"
<script setup lang="ts">
import {
  CheckIcon,
  ChevronsUpDownIcon,
  ZoomInIcon,
  ZoomOutIcon,
} from "@lucide/vue"
import {
  Select,
  SelectContent,
  SelectItem,
  SelectItemIndicator,
  SelectTrigger,
  SelectValue,
} from "@ui-sdk/vue/select"
import { Toolbar, ToolbarButton } from "@ui-sdk/vue/toolbar"
import { computed, ref } from "vue"
import { useLog } from "./log"

const zooms = ["50%", "75%", "100%", "150%", "200%"]

const log = useLog()
const zoom = ref("100%")
const index = computed(() => zooms.indexOf(zoom.value))

function change(value: string) {
  zoom.value = value
  log(`Zoom ${value}`)
}
</script>

<template>
  <Toolbar aria-label="View">
    <ToolbarButton
      aria-label="Zoom out"
      :disabled="index === 0"
      @click="change(zooms[index - 1])"
    >
      <ZoomOutIcon aria-hidden="true" />
    </ToolbarButton>
    <Select :value="zoom" @value-change="(value) => value && change(value)">
      <ToolbarButton aria-label="Zoom">
        <template #render="{ props }">
          <SelectTrigger v-bind="props">
            <SelectValue />
            <ChevronsUpDownIcon aria-hidden="true" />
          </SelectTrigger>
        </template>
      </ToolbarButton>
      <SelectContent>
        <SelectItem v-for="zoom in zooms" :key="zoom" :value="zoom">
          {{ zoom }}
          <SelectItemIndicator>
            <CheckIcon aria-hidden="true" />
          </SelectItemIndicator>
        </SelectItem>
      </SelectContent>
    </Select>
    <ToolbarButton
      aria-label="Zoom in"
      :disabled="index === zooms.length - 1"
      @click="change(zooms[index + 1])"
    >
      <ZoomInIcon aria-hidden="true" />
    </ToolbarButton>
  </Toolbar>
</template>
```

打开 Zoom 并选择一个值，或者用 Zoom out 和 Zoom in 步进它。每个按钮到达范围端点时会停用。

## 字段
文字字段用 `ToolbarInput`，也可以用它渲染另一个字段，比如 [Number Input](/docs/vue/components/number-input) 控件。字段保留 Home、End 和方向键，让它们在字段内移动光标。在对应的那一端，没有选中文本时，方向键会移到下一个条目。

用方向键进入字段时，光标会落在那个方向的远端：再按同一个方向键离开，或按另一个方向键编辑。Number Input 保留上、下方向键来步进它的值。

```vue title="input.vue"
<script setup lang="ts">
import { MinusIcon, PlusIcon } from "@lucide/vue"
import {
  NumberInput,
  NumberInputControl,
  NumberInputDecrement,
  NumberInputGroup,
  NumberInputIncrement,
} from "@ui-sdk/vue/number-input"
import { Toolbar, ToolbarInput, ToolbarSeparator } from "@ui-sdk/vue/toolbar"
</script>

<template>
  <Toolbar aria-label="Text">
    <NumberInput :default-value="14" :min="8" :max="72">
      <NumberInputGroup>
        <NumberInputDecrement aria-label="Decrease font size">
          <MinusIcon aria-hidden="true" />
        </NumberInputDecrement>
        <ToolbarInput>
          <template #render="{ props }">
            <NumberInputControl v-bind="props" aria-label="Font size" />
          </template>
        </ToolbarInput>
        <NumberInputIncrement aria-label="Increase font size">
          <PlusIcon aria-hidden="true" />
        </NumberInputIncrement>
      </NumberInputGroup>
    </NumberInput>
    <ToolbarSeparator />
    <ToolbarInput aria-label="Find" placeholder="Find…" />
  </Toolbar>
</template>
```

移到 Font size 并按上、下方向键改变它。在 Find 里输入一个词，把光标移到一端，再按那个方向键才会离开字段。

## 链接
`ToolbarLink` 加入同样的焦点顺序，并保留它的链接行为。示例自己处理普通点击，把带修饰键的点击（比如在新标签页打开）留给浏览器。

```vue title="link.vue"
<script setup lang="ts">
import { CheckIcon, MessageSquareIcon } from "@lucide/vue"
import {
  Toolbar,
  ToolbarButton,
  ToolbarLink,
  ToolbarSeparator,
} from "@ui-sdk/vue/toolbar"
import { useLog } from "./log"

const log = useLog()

function follow(event: MouseEvent) {
  if (
    event.button !== 0 ||
    event.metaKey ||
    event.ctrlKey ||
    event.shiftKey ||
    event.altKey
  ) {
    return
  }
  event.preventDefault()
  log(`Opened ${(event.currentTarget as HTMLAnchorElement).textContent}`)
}
</script>

<template>
  <Toolbar aria-label="Pull request">
    <ToolbarButton aria-label="Approve" @click="log('Approved')">
      <CheckIcon aria-hidden="true" />
    </ToolbarButton>
    <ToolbarButton aria-label="Comment" @click="log('Comment')">
      <MessageSquareIcon aria-hidden="true" />
    </ToolbarButton>
    <ToolbarSeparator />
    <ToolbarLink href="#files" @click="follow">Files Changed</ToolbarLink>
    <ToolbarLink href="#checks" @click="follow">Checks</ToolbarLink>
  </Toolbar>
</template>
```

用方向键移到 Files Changed 并按 Enter。控制台会记录它打开的页面。

## 垂直
设置 `orientation="vertical"` 改用上、下方向键，就像画布的工具面板。分隔线会跟着转，横跨工具栏。

```vue title="vertical.vue"
<script setup lang="ts">
import {
  MousePointer2Icon,
  PencilIcon,
  SquareIcon,
  Trash2Icon,
  TypeIcon,
} from "@lucide/vue"
import { Toggle, ToggleGroup, ToggleIcon } from "@ui-sdk/vue/toggle"
import { Toolbar, ToolbarButton, ToolbarSeparator } from "@ui-sdk/vue/toolbar"
import { useLog } from "./log"

const tools = [
  { value: "select", label: "Select", icon: MousePointer2Icon },
  { value: "draw", label: "Draw", icon: PencilIcon },
  { value: "shape", label: "Shape", icon: SquareIcon },
  { value: "text", label: "Text", icon: TypeIcon },
]

const log = useLog()
</script>

<template>
  <Toolbar orientation="vertical" aria-label="Canvas">
    <ToggleGroup
      :default-value="['select']"
      :deselectable="false"
      orientation="vertical"
      aria-label="Tool"
      @value-change="
        ([value]) =>
          log(`${tools.find((tool) => tool.value === value)?.label} tool`)
      "
    >
      <Toggle
        v-for="tool in tools"
        :key="tool.value"
        :value="tool.value"
        :aria-label="tool.label"
      >
        <ToggleIcon>
          <component :is="tool.icon" />
        </ToggleIcon>
      </Toggle>
    </ToggleGroup>
    <ToolbarSeparator />
    <ToolbarButton aria-label="Delete" @click="log('Deleted selection')">
      <Trash2Icon aria-hidden="true" />
    </ToolbarButton>
  </Toolbar>
</template>
```

用上、下方向键在工具和 Delete 之间移动。Space 选中获得焦点的工具。

## 禁用
禁用的条目通过 `aria-disabled` 保持可达，让人能找到它，但它会忽略按压，包括发给通过它渲染的组件的按键。把 `focusable-when-disabled` 设为 `false` 可以改为跳过它。

```vue title="disabled.vue"
<script setup lang="ts">
import { Toolbar, ToolbarButton } from "@ui-sdk/vue/toolbar"
import { useLog } from "./log"

const log = useLog()
</script>

<template>
  <Toolbar aria-label="Message">
    <ToolbarButton @click="log('Reply')">Reply</ToolbarButton>
    <ToolbarButton disabled @click="log('Archive')">Archive</ToolbarButton>
    <ToolbarButton
      disabled
      :focusable-when-disabled="false"
      @click="log('Delete')"
      >Delete</ToolbarButton
    >
  </Toolbar>
</template>
```

从 Reply 按方向键移到 Archive，它被禁用但可以聚焦。Delete 会被跳过。只有 Reply 会记录一次按压。

在工具栏上设置 `disabled` 会禁用每个条目。工具栏保留它的 Tab 停靠点，它的字段不能编辑。

```vue
<Toolbar disabled aria-label="Formatting">
  <ToolbarButton>Bold</ToolbarButton>
  <ToolbarInput aria-label="Find" />
</Toolbar>
```

## 循环
方向键默认会从最后一个条目绕回第一个。把 `loop` 设为 `false` 改为停在两端。

```vue title="loop.vue"
<script setup lang="ts">
import { Toolbar, ToolbarButton } from "@ui-sdk/vue/toolbar"
import { useLog } from "./log"

const log = useLog()
</script>

<template>
  <Toolbar :loop="false" aria-label="Pages">
    <ToolbarButton
      v-for="label in ['First', 'Previous', 'Next', 'Last']"
      :key="label"
      @click="log(`${label} page`)"
    >
      {{ label }}
    </ToolbarButton>
  </Toolbar>
</template>
```

聚焦 Last 并按右方向键。焦点留在那里；Home 仍然会移到 First。

## 控制器
用 `createToolbarController` 创建一个控制器，并作为 `controller` 传入。它的 `focus()` 把焦点移到上次聚焦的条目，就像编辑器给工具栏的 Alt+F10 快捷键。每个工具栏创建一个控制器。

```vue title="controller.vue"
<script setup lang="ts">
import { BoldIcon, ItalicIcon, LinkIcon } from "@lucide/vue"
import { useShortcut } from "@ui-sdk/vue/shortcuts"
import {
  createToolbarController,
  Toolbar,
  ToolbarButton,
} from "@ui-sdk/vue/toolbar"
import { useLog } from "./log"

const actions = [
  { label: "Bold", icon: BoldIcon },
  { label: "Italic", icon: ItalicIcon },
  { label: "Insert link", icon: LinkIcon },
]

const log = useLog()
const toolbar = createToolbarController()
useShortcut("alt+f10", () => toolbar.focus(), { allowInInput: true })
</script>

<template>
  <div data-slot="stack">
    <div data-slot="controls">
      <button type="button" @click="toolbar.focus()">Focus Toolbar</button>
    </div>
    <Toolbar :controller="toolbar" aria-label="Notes formatting">
      <ToolbarButton
        v-for="action in actions"
        :key="action.label"
        :aria-label="action.label"
        @click="log(action.label)"
      >
        <component :is="action.icon" aria-hidden="true" />
      </ToolbarButton>
    </Toolbar>
    <textarea aria-label="Notes" placeholder="Type, then press Alt+F10" />
  </div>
</template>
```

在 Notes 里输入，然后按 Alt+F10 或选择 Focus Toolbar。按压一个工具栏按钮，控制台会记录它。

## 自定义渲染
通过 `ToolbarButton` 或 `ToolbarInput` 渲染一个组件，把两者的行为组合起来，菜单、Select 和 Number Input 的示例就是这样做的。`#render` 槽位必须用 `v-bind` 把工具栏的 props 绑定到内部组件上。[部件与组合](/docs/vue/parts-and-composition)介绍了渲染约定。

## 样式
用根部件上的 `data-orientation` 表示行或列，用分隔线上的它表示线的走向，也就是横跨工具栏。用 `data-disabled` 为不可用的条目和分组设置样式。里面的切换按钮保留自己的 `data-pressed`。

每个部件都有一个 `data-slot`，比如 `toolbar-button`，它的状态属性列在[数据属性](https://ui-sdk.cn/docs/vue/components/toolbar#data-attributes)下。

## 数据属性
### Toolbar
`[data-slot="toolbar"]`

- `data-orientation` (`horizontal`, `vertical`): The toolbar's orientation. On a separator, which way the line runs: across the toolbar.
- `data-disabled`: Present when disabled, by the item itself, its group or the toolbar.

### ToolbarButton
`[data-slot="toolbar-button"]`

- `data-disabled`: Present when disabled, by the item itself, its group or the toolbar.
- `data-orientation` (`horizontal`, `vertical`): The toolbar's orientation. On a separator, which way the line runs: across the toolbar.

### ToolbarLink
`[data-slot="toolbar-link"]`

- `data-disabled`: Present when disabled, by the item itself, its group or the toolbar.
- `data-orientation` (`horizontal`, `vertical`): The toolbar's orientation. On a separator, which way the line runs: across the toolbar.

### ToolbarInput
`[data-slot="toolbar-input"]`

- `data-disabled`: Present when disabled, by the item itself, its group or the toolbar.
- `data-orientation` (`horizontal`, `vertical`): The toolbar's orientation. On a separator, which way the line runs: across the toolbar.

### ToolbarGroup
`[data-slot="toolbar-group"]`

- `data-disabled`: Present when disabled, by the item itself, its group or the toolbar.
- `data-orientation` (`horizontal`, `vertical`): The toolbar's orientation. On a separator, which way the line runs: across the toolbar.

### ToolbarSeparator
`[data-slot="toolbar-separator"]`

- `data-orientation` (`horizontal`, `vertical`): The toolbar's orientation. On a separator, which way the line runs: across the toolbar.

## API 参考
### Toolbar
- `orientation?` (`ToolbarOrientation`): Which arrow keys move between items: left and right, or up and down.
- `loop?` (`boolean`): Whether arrow keys wrap from the last item to the first.
- `disabled?` (`boolean`): Stops every item from being used. Items stay focusable with `aria-disabled`, so the toolbar keeps its tab stop and stays discoverable.
- `controller?` (`{ focus: () => void; }`): Focuses the toolbar from anywhere. Create one with `createToolbarController()`.
- `debug?` (`boolean`): Logs every state change with its reason to the console, in development builds.

### ToolbarButton
- `disabled?` (`boolean`): Stops the item from being used. It stays focusable with `aria-disabled`, so arrow keys still reach it and a tooltip can say why.
- `focusableWhenDisabled?` (`boolean`): Whether a disabled item stays reachable with arrow keys. Turn it off to skip it, natively disabled.

### ToolbarInput
- `disabled?` (`boolean`): Stops the item from being used. It stays focusable with `aria-disabled`, so arrow keys still reach it and a tooltip can say why.
- `focusableWhenDisabled?` (`boolean`): Whether a disabled item stays reachable with arrow keys. Turn it off to skip it, natively disabled.

### ToolbarGroup
- `disabled?` (`boolean`): Disables every item in the group. They stay focusable with `aria-disabled`.

`ToolbarLink` 和 `ToolbarSeparator` 没有自己的 props。

### 状态
`ToolbarButton` 和 `ToolbarInput` 上的渲染槽位会收到什么，以及 `ToolbarButton` 上的默认槽位：

- `disabled` (`boolean`): Whether the item is disabled, by itself, its group or the toolbar.
- `orientation` (`ToolbarOrientation`): The toolbar's `orientation` option: `"vertical"`, or `"horizontal"` for anything else.

在 `ToolbarLink` 上：

- `disabled` (`boolean`): Whether the link is disabled, by its group or the toolbar.
- `orientation` (`ToolbarOrientation`): The toolbar's `orientation` option: `"vertical"`, or `"horizontal"` for anything else.

在 `ToolbarSeparator` 上：

- `orientation` (`ToolbarOrientation`): Which way the line runs: across the toolbar, so vertical in a horizontal toolbar.

### 控制器
- `focus()` (`() => void`): Moves focus to the item that holds the toolbar's tab stop: the one focused last, or the first.

## 无障碍
工具栏遵循 [WAI-ARIA 工具栏模式](https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/)。根部件带有 `toolbar` 角色和 `aria-orientation`，分隔线带有 `separator` 角色。

### 键盘
工具栏只有一个 Tab 停靠点，即游走焦点（roving focus）。Tab 从第一个启用的条目进入，之后返回到上次聚焦的条目。再按 Tab 离开工具栏。

| 按键                       | 作用                                 |
| -------------------------- | ------------------------------------ |
| `ArrowRight` / `ArrowLeft` | 在水平工具栏里移动焦点               |
| `ArrowDown` / `ArrowUp`    | 在垂直工具栏里移动焦点               |
| `Home` / `End`             | 聚焦第一个或最后一个条目，字段里除外 |
| `Enter` / `Space`          | 激活按钮或切换按钮，或打开它的浮层   |

控件保留自己使用的按键：下方向键打开菜单，上、下方向键步进 Number Input。移动焦点永远不会按压切换按钮。在从右到左（RTL）的文本里，左、右方向键互换。

### 经过测试的行为
下面每一行都是一个自动化测试。

- The toolbar is named and has a horizontal orientation.
- Tab lands on the first item, and Tab again leaves the toolbar.
- Shift+Tab from after the toolbar lands on its tab stop.
- ArrowRight moves through every item, into toggle groups and out of fields.
- ArrowRight on the last item wraps to the first, and ArrowLeft back.
- Arrow keys never press a toggle, and Space and Enter do.
- Tab comes back to the item focused last.
- A toggle group in the toolbar is no tab stop of its own.
- A disabled button stays reachable, says it's disabled and does nothing.
- A button runs its action when pressed.
- A menu trigger rendered through a button opens with ArrowDown, and arrows still move past it.
- Choosing from a menu in the toolbar returns focus to its trigger.
- A text field keeps Home and End for its caret.
- Up and Down step a number field in the toolbar.
- Separators run across the toolbar.
- A group of buttons is named.
- A link in the toolbar follows its href with Enter.
- With loop off, arrows stop at the ends.
- A disabled toolbar keeps one tab stop, and every item says it's disabled.
- A toolbar button that renders a toggle is one item and one tab stop.

**Vertical**

- ArrowDown and ArrowUp move between items, and Left and Right don't.
- Separators run across a vertical toolbar.

**Disabled groups**

- Toggles and toggle groups in a disabled group are disabled.
- A link in a disabled group is disabled, and follows its href once enabled.
- Enabling a group enables the toggles and buttons in it.

Runs in React、Vue 和 web components.
