3 Pure CSS5 with JSPublished 2026-10-04Free · no sign-up
Eight ways to group buttons: an attached alignment group, an icon toolbar with arrow keys, segmented toggles, a Cancel and Save pair, pagination, a vertical action stack, filter chips and a quantity stepper.
Three buttons joined into one control, with shared borders and rounded outer corners only. The group is a role="group" with a label, so screen readers announce its purpose, and adjacent borders collapse with a negative margin.
An editor toolbar made of icon buttons in a pill, using role="toolbar" with arrow-key navigation so the group is one Tab stop. Each icon button has an aria-label, and toggle buttons such as Bold report their state with aria-pressed.
A rounded segmented control for switching a view between Day, Week and Month. It is built from buttons with aria-pressed rather than radios, which suits toolbars where the change happens straight away, and the active segment is raised.
The common footer pair of a quiet Cancel and a bold Save, aligned to the right. The primary action comes last in reading order to match most platforms, and both buttons have equal height so the pair looks balanced.
Page number buttons in an attached group with Previous and Next at the ends. It is a nav landmark labelled Pagination, the current page is marked with aria-current, and Previous is disabled on the first page.
A vertical group of actions for sidebars and side panels, with full-width buttons that share borders. A destructive action at the bottom is separated by a gap and coloured red, so it is not pressed by accident.
A wrapping group of toggle chips for quick filters, where several can be on at once. Each chip is a button with aria-pressed, a tick appears on active chips, and a Clear button resets them all in one click.
A minus, number and plus group for cart quantities. The buttons are named Decrease and Increase quantity, the number is a real input with min and max, and the minus button disables itself at the minimum.
Wrap related buttons in an element with role="group" or role="toolbar" and an aria-label, so screen readers announce what the buttons are for before reading them.
Toggle state
Buttons that switch something on or off use aria-pressed. Styling from that attribute keeps the look and the announced state in sync.
Toolbars and arrow keys
A toolbar is a single Tab stop: arrow keys move between its buttons, done with a roving tabindex. This keeps long toolbars from filling the Tab order.
Attached borders
Overlapping borders by a negative margin and rounding only the outer corners makes separate buttons read as one control, while each stays its own focusable button.
Frequently asked questions
Group or segmented control?
Use aria-pressed buttons when the change happens at once; use radio buttons inside a form.
Which demos need JavaScript?
Most, to toggle aria-pressed. The pair and vertical stack are pure CSS.
How do I keep focus rings visible on attached buttons?
Raise the focused button with position: relative and a z-index, as these demos do.