Toolbar
A row of related controls that share one tab stop and arrow-key movement.
SourceStyles source@monoline/react 0.5.0Markdown for AI toolsstable
- Built on radix-ui/Toolbar
- 4 parts, named exports
- role="toolbar" with a required name; one Tab stop, arrow keys move between controls.
- Home and End jump to the first and last control.
- Styles in one file:
toolbar.css
Import
import '@monoline/css';
import {Toolbar} from '@monoline/react';
Not installed yet? Pick a route.
Copies the source and its styles into your project.
npx monoline add toolbar
It needs radix-ui; install it if your project does not have it:
npm install radix-ui
Usage
import {Toolbar, ToolbarButton, ToolbarSeparator} from '@monoline/react';
<Toolbar aria-label="Text formatting">
<ToolbarButton>Bold</ToolbarButton>
<ToolbarButton>Italic</ToolbarButton>
<ToolbarButton>Underline</ToolbarButton>
<ToolbarSeparator />
<ToolbarButton>Link</ToolbarButton>
</Toolbar>
Anatomy
Import the parts you need and nest them like this.
import {Toolbar, ToolbarButton, ToolbarSeparator, ToolbarLink} from '@monoline/react';
<Toolbar>
<ToolbarButton />
<ToolbarSeparator />
<ToolbarLink />
</Toolbar>
Examples
Text formatting
Data Attributes
State is exposed through attributes. Style it with these selectors, not with class toggles.
| Attribute | Stylesheet |
|---|---|
[aria-pressed="true"] | toolbar.css |
[data-state="on"] | toolbar.css |
CSS classes
| Class | Stylesheet |
|---|---|
.toolbar | toolbar.css |
.toolbar-item | toolbar.css |
.toolbar-sep | toolbar.css |
Customization
Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.
app.css
.toolbar {
border-color: var(--accent);
}
.toolbar[aria-pressed="true"] {
background: var(--wash);
}
Accessibility
- role="toolbar" with a required name; one Tab stop, arrow keys move between controls.
- Home and End jump to the first and last control.
Keyboard
| Keys | Action |
|---|---|
| Arrow keys | Move between controls |
| Home / End | Jump to the first and last control |