Toolbar
Group of controls with one tab stop and arrow-key navigation.
- Browsers
- Chrome 123+Firefox 121+Safari 17.5+
- Tier
- 1
- Bundle compressed
- 2.04 kB
- Forced layout budget
- 0 ms
- Axe budget
- 0
- SSR compatible
- Yes
- Published contract
- Test harness
Playground
Toolbar
Default
import { Toolbar } from "@gunkin/uiify";
export default function Example() {
return (
<Toolbar.Root className="" aria-label="Formatting">
<Toolbar.Button>Bold</Toolbar.Button>
<Toolbar.Separator className="" />
<Toolbar.Button>Italic</Toolbar.Button>
</Toolbar.Root>
);
}/* Toolbar — grouped action buttons with separators. */
@layer components {
[data-uiify-toolbar][data-part="root"] {
display: inline-flex;
align-items: center;
gap: var(--space-xs);
padding: var(--space-xs);
border: var(--border-width) solid var(--border);
border-radius: var(--radius-full);
corner-shape: round;
background-color: var(--card);
}
[data-uiify-toolbar][data-part="root"] > hr[data-part="separator"][data-orientation] {
flex: none;
align-self: stretch;
inline-size: var(--border-width);
block-size: auto;
margin-inline: var(--space-md);
border: 0;
background-color: var(--border);
}
}import { Toolbar } from "@gunkin/uiify";
export default function Example() {
return (
<Toolbar.Root
className="
data-[part=root]:inline-flex data-[part=root]:items-center data-[part=root]:gap-xs data-[part=root]:p-xs
data-[part=root]:border-[length:var(--border-width)] data-[part=root]:border-solid
data-[part=root]:border-border data-[part=root]:rounded-[var(--radius-full)]
data-[part=root]:[corner-shape:round] data-[part=root]:bg-card
[&[data-part=root]>hr[data-part=separator][data-orientation]]:flex-none
[&[data-part=root]>hr[data-part=separator][data-orientation]]:self-stretch
[&[data-part=root]>hr[data-part=separator][data-orientation]]:[inline-size:var(--border-width)]
[&[data-part=root]>hr[data-part=separator][data-orientation]]:[block-size:auto]
[&[data-part=root]>hr[data-part=separator][data-orientation]]:mx-md
[&[data-part=root]>hr[data-part=separator][data-orientation]]:border-0
[&[data-part=root]>hr[data-part=separator][data-orientation]]:border-current
[&[data-part=root]>hr[data-part=separator][data-orientation]]:border-none
[&[data-part=root]>hr[data-part=separator][data-orientation]]:bg-border
"
aria-label="Formatting"
>
<Toolbar.Button>Bold</Toolbar.Button>
<Toolbar.Separator className="" />
<Toolbar.Button>Italic</Toolbar.Button>
</Toolbar.Root>
);
}/* app.css */
@layer reset, ui, app, tokens, base, demo, components, utilities, theme;
@import "@gunkin/uiify/styles/reset";
@import "@gunkin/uiify/components/behavior.css";
@import "@gunkin/uiify/styles/tokens";
@import "@gunkin/uiify/styles/tailwind";
@import "tailwindcss/utilities.css";
@theme { --spacing: 0.25rem; --font-weight-normal: 400; --font-weight-medium: 500; --font-weight-semibold: 600; --font-weight-bold: 700; }
@source inline('data-[part=root]:inline-flex data-[part=root]:items-center data-[part=root]:gap-xs data-[part=root]:p-xs data-[part=root]:border-[length:var(--border-width)] data-[part=root]:border-solid data-[part=root]:border-border data-[part=root]:rounded-[var(--radius-full)] data-[part=root]:[corner-shape:round] data-[part=root]:bg-card [&[data-part=root]>hr[data-part=separator][data-orientation]]:flex-none [&[data-part=root]>hr[data-part=separator][data-orientation]]:self-stretch [&[data-part=root]>hr[data-part=separator][data-orientation]]:[inline-size:var(--border-width)] [&[data-part=root]>hr[data-part=separator][data-orientation]]:[block-size:auto] [&[data-part=root]>hr[data-part=separator][data-orientation]]:mx-md [&[data-part=root]>hr[data-part=separator][data-orientation]]:border-0 [&[data-part=root]>hr[data-part=separator][data-orientation]]:border-current [&[data-part=root]>hr[data-part=separator][data-orientation]]:border-none [&[data-part=root]>hr[data-part=separator][data-orientation]]:bg-border');
@layer base { :root { --uiify-control-text: var(--text-sm); } @media (pointer: coarse) { :root { --uiify-control-text: var(--text-base); } } }
/* Authored animation and registered properties used by the Tailwind skin.
* Visual rules belong in utility recipes; only at-rule definitions live here. */
@layer components {
@keyframes uiify-presence-in {
from {
opacity: 0;
scale: var(--presence-scale);
}
}
}
@layer components {
@keyframes uiify-presence-out {
to {
opacity: 0;
scale: var(--presence-scale);
}
}
}
@property --uiify-spinner-tail {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
@property --uiify-spinner-length {
syntax: "<angle>";
inherits: false;
initial-value: 36deg;
}
@layer components {
@keyframes uiify-spinner-rotate {
to {
transform: rotate(360deg);
}
}
}
@layer components {
@keyframes uiify-spinner-orbit {
0% {
--uiify-spinner-tail: 0deg;
--uiify-spinner-length: 36deg;
}
50% {
--uiify-spinner-tail: 90deg;
--uiify-spinner-length: 324deg;
}
100% {
--uiify-spinner-tail: 360deg;
--uiify-spinner-length: 36deg;
}
}
}
@layer components {
@keyframes uiify-skeleton-pulse {
50% {
opacity: 0.45;
}
}
}
@layer components {
@keyframes uiify-skeleton-shimmer {
to {
background-position: -200% 0;
}
}
}
@layer components {
@keyframes uiify-skeleton-reveal {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
}
@property --candle-body-height {
syntax: "<percentage>";
inherits: true;
initial-value: 0%;
}
@property --candle-body-top {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --candle-slot {
syntax: "<percentage>";
inherits: true;
initial-value: 100%;
}
@property --candle-wick-height {
syntax: "<percentage>";
inherits: true;
initial-value: 0%;
}
@property --candle-wick-top {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --candle-x {
syntax: "<percentage>";
inherits: true;
initial-value: 0%;
}
@property --candle-scale {
syntax: "<number>";
inherits: true;
initial-value: 1;
}
@property --line-y {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --line-prev-y {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --line-count {
syntax: "<integer>";
inherits: false;
initial-value: 1;
}
@property --line-scale {
syntax: "<number>";
inherits: true;
initial-value: 1;
}
@layer components {
@keyframes uiify-otp-input-caret-blink {
50% {
opacity: 0;
}
}
}API
Toolbar.Root
| Prop | Type | Default | Description |
|---|---|---|---|
dir | "ltr" | "rtl" | — | Writing direction, which flips what the left and right arrow keys do. |
loop | boolean | true | Whether arrow-key navigation wraps around at the first and last item. |
orientation | "horizontal" | "vertical" | "both" | "horizontal" | Which arrow keys move focus between items, and the data-orientation value. |
Toolbar.Button
| Prop | Type | Default | Description |
|---|---|---|---|
selected | boolean | — | Toggle state of the button: sets aria-pressed and, when true, data-selected and the primary fill. |
children | ReactNode | — | Content of the button. |
className | string | — | Class applied to the button element. |
disabled | boolean | false | Disables the button and takes it out of the roving-focus order. |
Toolbar.Link
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Content of the link. |
className | string | — | Class applied to the anchor element. |
href* | string | — | Destination of the link, which navigates without JavaScript. |
Toolbar.Separator
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Class applied to the <hr> element. |
orientation | "horizontal" | "vertical" | "vertical" | Sets aria-orientation and data-orientation on the separator. |
Toolbar.ToggleGroup
| Prop | Type | Default | Description |
|---|---|---|---|
id* | string | — | Base for the deterministic ids and the shared input group name. |
type | "single" | "multiple" | "single" | Whether one or several toggles may be pressed, choosing radio or checkbox inputs. |
items* | readonly ToggleGroupItem[] | — | Each item is { value, label, disabled? }. |
defaultValue | string | readonly string[] | undefined | — | Pressed on first render. Uncontrolled, so it survives with no JavaScript. |
orientation | "horizontal" | "vertical" | "horizontal" | Direction the toggles are laid out in. |
className | string | — | Class applied to the group root. |
Keyboard
| Key | Action |
|---|---|
| Tab | Move focus to/from the control |
| Enter / Space | Activate when focused (button-like controls) |
Accessibility
Uses semantic HTML where possible. Inspect rendered markup in the playground — ARIA is added only when native elements are insufficient.
Styling hooks
data-disabled