Skip to content

ButtonGroup

Joins several Buttons into one set. The corners that face a neighbour are squared off, and shared props are set once on the group.

tsx
import { Button, ButtonGroup } from 'neba';

<ButtonGroup variant="outline">
  <Button>Day</Button>
  <Button>Week</Button>
  <Button>Month</Button>
</ButtonGroup>;

Props

PropTypeDefaultDescription
variantshared'solid' | 'outline' | 'text'Applied to every button in the group. Unset means the Button's own default stands
sizeshared'xs' | 'sm' | 'md' | 'lg' | 'xl'Height and type scale for every button in the group
colorshared'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info'Colour role for every button in the group. A button's own prop still wins
densityshared'default' | 'compact'Horizontal padding for every button in the group
elevationshared0 | 1 | 2 | 3Drop shadow depth for every button in the group
orientationshared'horizontal' | 'vertical''horizontal'Which way the buttons run. Vertical flattens the top and bottom corners instead
disabledbooleanDisables every button in the group at once
fullWidthbooleanfalseStretches to the container and divides the width evenly between the buttons
childrenReactNodeThe buttons. The shared props reach them even through a wrapper

Every native <div> attribute passes straight through, minus color.

Examples

Shared props

variant · size · color · density · elevation · disabled set on the group reach every child Button. A value set on a button overrides the group's, so one danger button can sit in a row of secondary actions.

orientation

vertical stacks the buttons and squares off the top and bottom corners instead.

fullWidth

Stretches the group to the container width, with the buttons sharing the space equally.

Accessibility

  • Renders role="group". Give it an aria-label when the button labels alone do not say what the set is for.
  • It does not manage selection. For one-of-a-set, use SegmentedButton or RadioGroup.
  • The hovered or focused button is raised above its neighbours so its focus ring is never clipped.

Released under the MIT License