Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Global Navigation

  • Navbar
  • BeianFooter
  • Brand
  • AppLauncher
  • Sidebar
  • NavMenu
  • NavigationMenu
  • Menu
  • Menubar
  • Dock
  • BubbleMenu
  • CardNav
  • FlowingMenu
  • GooeyNav
  • PillNav
  • StaggeredMenu

In-page Navigation

  • RouteTabs
  • Tabs
  • Breadcrumb
  • Pagination
  • Anchor
  • Affix
  • BackTop
  • Stepper
  • Steps
  • PageHeader

Actions and Tools

  • Command
  • ContextMenu
  • Toolbar
  • Accordion
  • Collapsible
  • Link
  • AnimatedThemeToggler

Toolbar

toolbar

Groups related action controls with roving keyboard focus.

Usage

Basic usage

role=toolbar Container built-in keyboard roaming (arrow keys move focus). ToolbarButton is an ordinary button.

tsx
<Toolbar aria-label="Text Format">
  <ToolbarButton aria-label="Share"><Share2 className="size-4" />Share</ToolbarButton>
</Toolbar>

Switchable button

ToolbarToggle is an uncontrolled switch, and defaultPressed is set to be initially selected. The selected state is filled with the main color, which is different from hover.

tsx
<Toolbar aria-label="Text Format">
  <ToolbarToggle aria-label="Bold" defaultPressed><Bold className="size-4" /></ToolbarToggle>
  <ToolbarToggle aria-label="italic"><Italic className="size-4" /></ToolbarToggle>
  <ToolbarToggle aria-label="underline"><Underline className="size-4" /></ToolbarToggle>
</Toolbar>

Group + Delimiter

ToolbarGroup aggregates related buttons, ToolbarSeparator inserts vertical lines between groups.

tsx
<Toolbar aria-label="Text Format">
  <ToolbarGroup>
    <ToolbarToggle aria-label="Bold" defaultPressed><Bold className="size-4" /></ToolbarToggle>
    <ToolbarToggle aria-label="italic"><Italic className="size-4" /></ToolbarToggle>
  </ToolbarGroup>
  <ToolbarSeparator />
  <ToolbarGroup>
    <ToolbarToggle aria-label="Left justified" defaultPressed><AlignLeft className="size-4" /></ToolbarToggle>
    <ToolbarToggle aria-label="center"><AlignCenter className="size-4" /></ToolbarToggle>
    <ToolbarToggle aria-label="right-justified"><AlignRight className="size-4" /></ToolbarToggle>
  </ToolbarGroup>
  <ToolbarSeparator />
  <ToolbarButton aria-label="Share"><Share2 className="size-4" />Share</ToolbarButton>
</Toolbar>

When to use

Use Toolbar for a persistent horizontal or vertical set of related controls such as rich-text formatting, alignment, and sharing. It provides role=toolbar and arrow-key focus movement. Use ContextMenu for actions opened on demand or Command for a Command/Ctrl+K searchable palette.

Import

ts
import { Toolbar, ToolbarButton, ToolbarToggle, ToolbarGroup, ToolbarSeparator } from "@hulianui/ui"

Props

Toolbar

NameTypeDefaultDescription
orientation"horizontal" | "vertical""horizontal"Layout direction.
disabledboolean-Whether the entire toolbar is disabled.
loopFocusbooleantrueWhether keyboard navigation wraps after the final control.
aria-labelstring-Accessible toolbar label.
classNamestring-Additional class name.

ToolbarButton

NameTypeDefaultDescription
disabledboolean-Whether the button is disabled.
aria-labelstring-Accessible label, required for an icon-only button.
classNamestring-Additional class name.

ToolbarToggle

NameTypeDefaultDescription
pressedboolean-Controlled pressed state.
defaultPressedbooleanfalseInitial pressed state when uncontrolled.
disabledboolean-Whether the toggle is disabled.
aria-labelstring-Accessible label.
classNamestring-Additional class name.

ToolbarGroup: props disabled / aria-label / className; slot children.
ToolbarSeparator: props orientation?: "horizontal" \| "vertical" / className; orientation defaults to "vertical", independently of the root Toolbar's "horizontal" default.

Events

EventTypeDescription
onClick(e: MouseEvent<HTMLButtonElement>) => voidToolbarButton click handler.
onPressedChange(pressed: boolean) => voidCalled when ToolbarToggle changes state.

Slots

SlotTypeDescription
childrenReactNodeChild content of Toolbar, ToolbarButton, ToolbarToggle, or ToolbarGroup.

Example

tsx
<Toolbar aria-label="Text formatting">
  <ToolbarGroup>
    <ToolbarToggle aria-label="Bold" defaultPressed><Bold className="size-4" /></ToolbarToggle>
    <ToolbarToggle aria-label="Italic"><Italic className="size-4" /></ToolbarToggle>
  </ToolbarGroup>
  <ToolbarSeparator />
  <ToolbarButton aria-label="Share"><Share2 className="size-4" />Share</ToolbarButton>
</Toolbar>

Usage guidelines

  • Add aria-label to icon-only ToolbarButton and ToolbarToggle controls so screen readers can identify them.
  • Choose either controlled pressed or uncontrolled defaultPressed for each ToolbarToggle. Mixing both can desynchronize state.

Related

Command · ContextMenu · Accordion · Collapsible · Link · AnimatedThemeToggler

PreviousContextMenuNavigationNextAccordion

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Slots
    • Example
    • Usage guidelines
    • Related