Skip to content

Button Group

Joins related buttons into one segmented control.

Installation

bun add @xerobi/ui
import { ButtonGroup, ButtonGroupSeparator, ButtonGroupText } from "@xerobi/ui/button-group"

This component is client-side. In Astro, hydrate it with a client directive.

Examples

Split button

import { ChevronDownIcon } from "lucide-react"
import { Button } from "@xerobi/ui/button"
import { ButtonGroup, ButtonGroupSeparator } from "@xerobi/ui/button-group"

export function ButtonGroupSplit() {
  return (
    <ButtonGroup>
      <Button>Deploy</Button>
      <ButtonGroupSeparator />
      <Button size="icon" aria-label="Deployment options">
        <ChevronDownIcon />
      </Button>
    </ButtonGroup>
  )
}

Segmented actions

import { Button } from "@xerobi/ui/button"
import { ButtonGroup, ButtonGroupSeparator } from "@xerobi/ui/button-group"

export function ButtonGroupSegmented() {
  return (
    <ButtonGroup>
      <Button variant="outline">Day</Button>
      <Button variant="outline">Week</Button>
      <Button variant="outline">Month</Button>
    </ButtonGroup>
  )
}

Variants

orientationhorizontal, vertical

API reference

ButtonGroup

Also accepts every prop of <div> element.

PropTypeDescription
orientation"horizontal" | "vertical"

ButtonGroupSeparator

No props of its own.

ButtonGroupText

No props of its own.

Styling hooks: [data-slot="button-group"], [data-slot="button-group-separator"].

Search documentation

Search pages, components and blocks.