Skip to content
VinUIComponentsButton Group

Button Group

Related buttons joined into one control. Same markup and props in every style: switch the style in the header to see it change.

Basic

Put any Buttons inside. The corners and borders between them join up in every style.

button-group-basic.html
<div class="vin-btn-group" role="group" aria-label="Message actions">
  <button type="button" class="vin-btn vin-btn--outline">Archive</button>
  <button type="button" class="vin-btn vin-btn--outline">Report</button>
  <button type="button" class="vin-btn vin-btn--outline">Snooze</button>
</div>
<div class="vin-btn-group" role="group" aria-label="History">
  <button type="button" class="vin-btn vin-btn--secondary">Undo</button>
  <button type="button" class="vin-btn vin-btn--secondary">Redo</button>
</div>

Split button

A main action with a second button for more options.

button-group-split.html
<div class="vin-btn-group" role="group" aria-label="Save">
  <button type="button" class="vin-btn">Save changes</button>
  <button type="button" class="vin-btn vin-btn--icon" aria-label="More save options">
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg>
  </button>
</div>

Vertical

Stacked buttons, for side panels and narrow toolbars.

button-group-vertical.html
<div class="vin-btn-group vin-btn-group--vertical" role="group" aria-label="Align">
  <button type="button" class="vin-btn vin-btn--outline">Top</button>
  <button type="button" class="vin-btn vin-btn--outline">Middle</button>
  <button type="button" class="vin-btn vin-btn--outline">Bottom</button>
</div>

Installation

React, Vue and Svelte: add the component to your project with the CLI. It reads your framework from vin.json and also copies any component this one needs. Then import it:

Terminal
npx @vinish/ui add button-group
React
import { ButtonGroup } from "@/components/vin/button-group";
Vue
import ButtonGroup from "@/components/vin/button-group.vue";
Svelte
import ButtonGroup from "$lib/components/vin/button-group.svelte";

The import paths assume the default folders: @/components/vin (React and Vue, with the usual @ → src alias) and $lib/components/vin (SvelteKit). Use your own if you chose another folder in init. How the Vue and Svelte versions pass values and content is in Frameworks.

Plain HTML: the classes come with the style's stylesheet. It needs no JavaScript.

API

From spec/button-group.json, which every framework version is tested against.

PropValuesDefaultIn HTML
orientationhorizontalverticalhorizontalvin-btn-group--vertical
aria-label
Names the group for screen readers.
string—role="group" aria-label="…"

Parts

React, Vue, SvelteHTML classes
<ButtonGroup>.vin-btn-group.vin-btn-group--vertical

Accessibility

  • role="group" with an aria-label tells screen readers the buttons belong together.
  • Each button keeps its own label and stays in the Tab order.
  • Icon-only buttons in a group still need an aria-label.
  • For on/off choices, use Toggle Group instead, so the pressed state is announced.