Playground

Button group

Join related buttons into one segmented bar.

  • Built on native elements
  • role="group" with a required accessible name.
  • Styles in one file: 02-buttons.css

Import

import '@monoline/css';
import {ButtonGroup} from '@monoline/react';

Not installed yet? Pick a route.

Copies the source and its styles into your project.

npx monoline add button-group

Usage

import {Button, ButtonGroup} from '@monoline/react';

<ButtonGroup aria-label="View">
  <Button variant="line">Day</Button>
  <Button variant="line">Week</Button>
  <Button variant="line">Month</Button>
</ButtonGroup>

Examples

Basic

Props

ButtonGroupProps

PropTypeDefaultDescription
aria-label requiredstring–Names the group for assistive tech, for example "Text alignment".

Data Attributes

State is exposed through attributes. Style it with these selectors, not with class toggles.

This component sets no state attributes.

CSS classes

ClassStylesheet
.btn02-buttons.css
.btn-block02-buttons.css
.btn-danger02-buttons.css
.btn-ghost02-buttons.css
.btn-lg02-buttons.css
.btn-line02-buttons.css
.btn-sm02-buttons.css
.btn-solid02-buttons.css
.btnbutton-group.css
.btn-groupbutton-group.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
.btn {
  border-color: var(--accent);
}

Accessibility

  • role="group" with a required accessible name.