Toolbar
A container for grouping a set of buttons and controls.
Usage guidelines
To ensure that toolbars are accessible and helpful, follow these guidelines:
- Use inputs sparingly: Left and right arrow keys are used to both move the text insertion cursor in an input, and to navigate among controls in horizontal toolbars. When using an input in a horizontal toolbar, use only one and place it as the last element of the toolbar.
Anatomy
Import the component and assemble its parts:
Examples
Using with Menu
All Sveltery Base popup components that provide a Trigger component can be integrated with a toolbar by passing the trigger to <Toolbar.Button> with the render snippet:
This applies to <AlertDialog>, <Dialog>, <Menu>, <Popover>, and <Select>.
Using with Tooltip
Unlike other popups, the toolbar item should be passed to the render snippet of <Tooltip.Trigger>:
Using with NumberField
To use a NumberField in the toolbar, pass <NumberField.Input> to <Toolbar.Input> using the render snippet:
API reference
Root
A container for grouping a set of controls. Renders a <div>.
disabled boolean | null false
- Name
- Description
Whether the toolbar's buttons ignore user interaction. Links stay active.
- Type
boolean | null- Default
false
orientation ToolbarOrientation 'horizontal'
- Name
- Description
The orientation of the toolbar.
- Type
ToolbarOrientation- Default
'horizontal'
loopFocus boolean true
- Name
- Description
When
true, keyboard navigation wraps from the last item to the first.- Type
boolean- Default
true
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ToolbarRootState, children: Snippet | undefined]> —
- Name
- Description
Replace the default
<div>. Spreadpropsonto the host element.- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ToolbarRootState, children: Snippet | undefined]>
disabled boolean
- Name
disabled- Description
Whether the toolbar should ignore user interaction.
- Type
boolean
orientation ToolbarOrientation
- Name
orientation- Description
The toolbar orientation.
- Type
ToolbarOrientation
data-orientation
data-disabled
Button
A button in a toolbar. Renders a <button>.
disabled boolean | null false
- Name
- Description
Whether the button should ignore user interaction.
- Type
boolean | null- Default
false
focusableWhenDisabled boolean true
- Description
Whether a disabled button stays in the toolbar's arrow order.
- Type
boolean- Default
true
nativeButton boolean true
- Name
- Description
Whether the host is a native
<button>. Setfalsewhenrendersupplies a non-button element.- Type
boolean- Default
true
onclick MouseEventHandler<HTMLButtonElement> | null —
- Name
- Description
Runs for a click the button does not ignore.
- Type
MouseEventHandler<HTMLButtonElement> | null
render Snippet<[props: ToolbarButtonHostProps, state: ToolbarButtonState, children: Snippet | undefined]> —
- Name
- Description
Replace the default
<button>. Spreadpropsonto the host element.- Type
Snippet<[props: ToolbarButtonHostProps, state: ToolbarButtonState, children: Snippet | undefined]>
disabled boolean
- Name
disabled- Description
Whether the button should ignore user interaction.
- Type
boolean
focusable boolean
- Name
focusable- Description
Whether the button remains focusable when disabled.
- Type
boolean
orientation ToolbarOrientation
- Name
orientation- Description
The toolbar orientation.
- Type
ToolbarOrientation
data-orientation
data-disabled
data-focusable
Link
A link in a toolbar. Renders an <a>.
render Snippet<[props: ToolbarLinkHostProps, state: ToolbarLinkState, children: Snippet | undefined]> —
- Name
- Description
Replace the default
<a>. Spreadpropsonto the host element.- Type
Snippet<[props: ToolbarLinkHostProps, state: ToolbarLinkState, children: Snippet | undefined]>
orientation ToolbarOrientation
- Name
orientation- Description
The toolbar orientation.
- Type
ToolbarOrientation
data-orientation
Input
A native input in a toolbar's arrow order. Renders an <input>.
disabled boolean | null false
- Name
- Description
Whether the input should ignore user interaction. A disabled input gets
aria-disabled, not thedisabledattribute.- Type
boolean | null- Default
false
focusableWhenDisabled boolean true
- Description
Whether a disabled input stays in the toolbar's arrow order.
- Type
boolean- Default
true
render Snippet<[props: ToolbarInputHostProps, state: ToolbarInputState]> —
- Name
- Description
Replace the default
<input>. Spreadpropsonto the host element.- Type
Snippet<[props: ToolbarInputHostProps, state: ToolbarInputState]>
disabled boolean
- Name
disabled- Description
Whether the input should ignore user interaction.
- Type
boolean
focusable boolean
- Name
focusable- Description
Whether the input remains focusable when disabled.
- Type
boolean
orientation ToolbarOrientation
- Name
orientation- Description
The toolbar orientation.
- Type
ToolbarOrientation
data-orientation
data-disabled
data-focusable
Group
Groups several toolbar items. Renders a <div>.
disabled boolean | null false
- Name
- Description
Whether every button in the group ignores user interaction. Links stay active.
- Type
boolean | null- Default
false
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ToolbarGroupState, children: Snippet | undefined]> —
- Name
- Description
Replace the default
<div>. Spreadpropsonto the host element.- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: ToolbarGroupState, children: Snippet | undefined]>
disabled boolean
- Name
disabled- Description
Whether the toolbar should ignore user interaction.
- Type
boolean
orientation ToolbarOrientation
- Name
orientation- Description
The toolbar orientation.
- Type
ToolbarOrientation
data-orientation
data-disabled
Separator
A separator in a toolbar. Renders a <div>.
orientation ToolbarOrientation 'horizontal'
- Name
- Description
The orientation of the separator. Defaults to the opposite of the toolbar's orientation, so a horizontal toolbar renders vertical separators.
- Type
ToolbarOrientation- Default
'horizontal'
render Snippet<[props: HTMLAttributes<HTMLDivElement>, state: SeparatorState, children: Snippet | undefined]> —
- Name
- Description
Replace the default
<div>. Spreadpropsonto the host element.- Type
Snippet<[props: HTMLAttributes<HTMLDivElement>, state: SeparatorState, children: Snippet | undefined]>
orientation 'horizontal' | 'vertical'
- Name
orientation- Description
The orientation of the separator.
- Type
'horizontal' | 'vertical'