|$ curl https://forge-ai.dev/api/markdown?path=docs/components/toolbar
$cat docs/toolbar.md
updated Recently·22 min read·published

Toolbar

CSSHTMLTailwindBootstrapUIIntermediate🎯Free Tools
Introduction

A toolbar groups related controls — buttons, toggles, inputs, menus — into a single navigable region. You will find them in rich-text editors, media players, IDEs, and data tables. This guide covers production-ready toolbar patterns in plain HTML/CSS, Tailwind CSS, and Bootstrap, including roving tabindex, separators, overflow menus, and ARIA.

info

Wrap a toolbar with role="toolbar", give it an aria-label, and use arrow keys with a roving tabIndex so only one control is in the tab order at a time.
Basic Toolbar

A horizontal formatting toolbar with toggle buttons for bold, italic, underline, and a link action separated by a visual divider.

basic
Live
untitled.html
HTML
1<div class="toolbar" role="toolbar" aria-label="Text formatting" aria-orientation="horizontal">
2 <button class="btn toggle" aria-pressed="false">
3 B
4 </button>
5 <button class="btn toggle" aria-pressed="false">
6 I
7 </button>
8 <button class="btn toggle" aria-pressed="false">
9 U
10 </button>
11 <div role="separator" aria-orientation="vertical" class="sep">
12 </div>
13 <button class="btn">
14 Link
15 </button>
16</div>
preview
Icon Toolbar

Compact icon-only controls are common in IDEs and media players. Every icon button must carry an aria-label.

icons
Live
untitled.html
HTML
1<div class="toolbar" role="toolbar" aria-label="Editor actions">
2 <button class="icon" aria-label="Undo">
3 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
4 <path d="M3 7v6h6"/>
5 <path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/>
6 </svg>
7 </button>
8 <button class="icon" aria-label="Redo">
9 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
10 <path d="M21 7v6h-6"/>
11 <path d="M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"/>
12 </svg>
13 </button>
14 <button class="icon" aria-label="Cut">
15 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
16 <circle cx="6" cy="6" r="3"/>
17 <circle cx="6" cy="18" r="3"/>
18 <line x1="20" y1="4" x2="8.12" y2="15.88"/>
19 <line x1="14.47" y1="14.48" x2="20" y2="20"/>
20 <line x1="8.12" y1="8.12" x2="12" y2="12"/>
21 </svg>
22 </button>
23 <button class="icon" aria-label="Copy">
24 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
25 <rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
26 <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
27 </svg>
28 </button>
29 <button class="icon" aria-label="Paste">
30 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
31 <path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/>
32 <rect x="8" y="2" width="8" height="4" rx="1" ry="1"/>
33 </svg>
34 </button>
35</div>
preview
View Switcher

A segmented control toolbar. Only one option is active; the rest are inactive but still focusable via arrow keys.

switcher
Live
untitled.html
HTML
1<div class="toolbar" role="toolbar" aria-label="View layout">
2 <button class="seg active">
3 List
4 </button>
5 <button class="seg">
6 Grid
7 </button>
8 <button class="seg">
9 Board
10 </button>
11</div>
preview
Overflow Menu

When space is limited, move secondary actions behind a "more" button with aria-haspopup and aria-expanded.

overflow
Live
untitled.html
HTML
1<div class="toolbar" role="toolbar" aria-label="Formatting">
2 <button class="btn">
3 Bold
4 </button>
5 <button class="btn">
6 Italic
7 </button>
8 <div class="overflow">
9 <button class="btn more" aria-haspopup="true" aria-expanded="false">
10
11 </button>
12 <div class="menu hidden">
13 <button class="menu-item">
14 Underline
15 </button>
16 <button class="menu-item">
17 Strikethrough
18 </button>
19 <button class="menu-item">
20 Code
21 </button>
22 </div>
23 </div>
24</div>
preview
Vertical Toolbar

Set aria-orientation="vertical" and use Up/Down arrows for roving focus in narrow sidebars.

vertical
Live
untitled.html
HTML
1<div class="toolbar" role="toolbar" aria-label="Tools" aria-orientation="vertical">
2 <button class="icon" aria-label="Select">
3 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
4 <path d="M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"/>
5 </svg>
6 </button>
7 <button class="icon" aria-label="Brush">
8 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
9 <path d="M18 11.5V9a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v1.5"/>
10 <path d="M14 10V8a2 2 0 0 0-2-2v0a2 2 0 0 0-2 2v2"/>
11 <path d="M10 9.5V12a2 2 0 0 0 2 2v0"/>
12 <path d="M16 12a2 2 0 0 1-2 2v0"/>
13 <path d="M20 18a2 2 0 1 1-4 0c0-1.5 2-2 2-4 0 2 2 2.5 2 4z"/>
14 </svg>
15 </button>
16 <button class="icon" aria-label="Eraser">
17 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
18 <path d="M7 21l-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/>
19 <path d="M22 21H7"/>
20 <path d="M5 11l9 9"/>
21 </svg>
22 </button>
23 <button class="icon" aria-label="Text">
24 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" width="18" height="18">
25 <path d="M4 7V5h16v2"/>
26 <path d="M9 20h6"/>
27 <path d="M12 5v14"/>
28 </svg>
29 </button>
30</div>
preview
Toolbar with Input

Toolbars can include non-button controls such as a search field. The input remains a regular tab stop while buttons use roving focus.

input
Live
untitled.html
HTML
1<div class="toolbar" role="toolbar" aria-label="File search">
2 <button class="btn">
3 New
4 </button>
5 <button class="btn">
6 Open
7 </button>
8 <div role="separator" aria-orientation="vertical" class="sep">
9 </div>
10 <input type="text" class="search" placeholder="Search files..." aria-label="Search files" />
11</div>
preview
Accessibility

Toolbars are composite widgets, so keyboard behavior and screen-reader semantics matter as much as visual styling.

  • Apply role="toolbar" to the container and a descriptive aria-label.
  • Use aria-orientation to declare horizontal or vertical layout.
  • Implement roving tabIndex: only the active control has tabIndex="0"; siblings have tabIndex="-1".
  • Move focus with Left/Right in horizontal toolbars and Up/Down in vertical toolbars.
  • Mark toggle buttons with aria-pressed and update it when state changes.
  • Icon-only buttons must include an aria-label or visually hidden text.
  • Place role="separator" between logical groups and give it an orientation.
  • Keep focus indicators visible; never remove focus rings without a replacement.
$Blueprint — Engineering Documentation·Section ID: UI-TB-01·Revision: 1.1

Community

Get help on Slack, Discord or VIP

Stuck on a guide? Join the community and ask.