Skip to content

Editor Button Toolbar

Dark Bootstrap 5 text editor toolbar with grouped icon buttons, toggle states, a block style dropdown, arrow key navigation and a working editable area.

Also known as: rich text editor toolbar, wysiwyg toolbar, text formatting toolbar, editor button group

Bootstrap 5 Button Groups Responsive Dark #button-group #dark #editor #icons #toolbar

Editor Button Toolbar live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A dark Bootstrap 5 button toolbar for a rich text editor, with icon buttons grouped into history, block style, text style, alignment, lists and insert sections, connected to a small editable document so every button really works. Use it for comment boxes, CMS fields, note apps and admin panels.

How it works

The root is section.etb-editor with data-bs-theme="dark", so Bootstrap's own parts (like the dropdown) match the dark design. Inside .etb-shell, the .etb-toolbar is a Bootstrap btn-toolbar with role="toolbar". Each .etb-group is a btn-group with role="group" and its own aria-label. Every .etb-btn carries a data-etb-cmd value such as bold, justifyCenter or insertOrderedList. The block style menu is a Bootstrap dropdown whose items use data-etb-block (p, h2, h3, blockquote). Below the toolbar sits the .etb-area editing surface (contenteditable), and .etb-footer shows a live word count in .etb-count.

The script stores the current text selection on every selectionchange inside the area. A mousedown handler on the toolbar prevents the selection from being lost, and before each command the saved range is restored, then document.execCommand() runs and focus returns to the button. After each change the script asks queryCommandState() which styles are active and sets aria-pressed on the toggle buttons, which turns them amber. The dropdown label shows the current block type from queryCommandValue('formatBlock').

Customization

  • --etb-accent and --etb-accent-rgb in .etb-editor: change the amber color of pressed buttons, focus outlines, caret and quotes.
  • --etb-shell-bg, --etb-bar-bg and --etb-border in .etb-editor: adjust the editor and toolbar surfaces.
  • --etb-radius in .etb-editor: make the buttons square or rounder.
  • Add a button with a data-etb-cmd value (for example subscript) to an .etb-group; add the command to STATEFUL in script.js if it should show a pressed state.
  • Add an item with data-etb-block to .etb-menu and a label in BLOCK_NAMES for more block types.
  • min-height and max-height in .etb-area: change the size of the writing area.
  • Remove data-bs-theme="dark" and override the custom properties for a light toolbar.

Use cases

  • Comment boxes: readers format replies with bold, italic, lists and links from a compact toolbar
  • CMS and blog editors: grouped history, block style, alignment and insert buttons work on a live editable area
  • Note-taking apps: toggle buttons light up to show the active text style at the cursor
  • Admin panels: a dark toolbar with arrow key navigation fits back-office content fields

Accessibility

The toolbar follows the ARIA toolbar pattern with a roving tabindex: only one button is in the Tab order, and the Left and Right arrow keys, Home and End move between buttons. Toggle buttons expose aria-pressed, every icon button has an aria-label plus a title tooltip with its shortcut, and icons are aria-hidden. The dropdown toggle's label announces the current block style. The editable area has role="textbox", aria-multiline and a label, and native shortcuts such as Ctrl+B still work and update the button states. Focus is shown with a solid amber outline.

Usage notes

Requires Bootstrap 5 (bundle with Popper for the dropdown) and Bootstrap Icons. execCommand is deprecated but still supported by all major browsers; for production editors, keep this toolbar markup and connect the buttons to an editor library instead. Sanitize the HTML on the server before saving it.

Editor Button Toolbar at a glance

Framework
Bootstrap 5
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 5, Bootstrap Icons
Layout
Responsive, works on mobile, dark design
Category
Button Groups
License
Free for personal and commercial use

Questions about this template

Can I use the Editor Button Toolbar code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 5 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  • <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Editor Button Toolbar – free Bootstrap 5 button group template
Editor Button Toolbar · free Bootstrap 5 button group template

More Button Groups

Pill Button Group Toggle – free Pure CSS button group template

Pill Button Group Toggle

Pure CSS pill button group built on radio buttons, with a colored background that slides to the selected option. No JavaScript needed.

Split Button Dropdown – free Bootstrap 5 button group template

Split Button Dropdown

Bootstrap 5 split buttons: a primary deploy action whose target is chosen from an attached dropdown, plus compact save and export split buttons.

Segmented Control – free Tailwind CSS button group template

Segmented Control

Tailwind CSS segmented control with a sliding thumb, built on native radio inputs for single-choice view, range and billing toggles.