Skip to main content

Starwind UI v3.0 is now available! Migration guide

Button Group

Installation

Usage

---
import { Button } from "@/components/starwind/button";
import { ButtonGroup } from "@/components/starwind/button-group";
---
<ButtonGroup>
<Button variant="outline">Left</Button>
<Button variant="outline">Middle</Button>
<Button variant="outline">Right</Button>
</ButtonGroup>

Composition

Place buttons, inputs, text, or separators inside the group:

ButtonGroup
├── Button or Input
├── ButtonGroupSeparator
└── ButtonGroupText

Orientation

Set the orientation prop to change the button group layout.

Size

Control the size of buttons using the size prop on individual buttons.

Nested

Nest ButtonGroup components to create button groups with spacing.

Separator

The ButtonGroupSeparator component visually divides buttons within a group.

Buttons with variant outline do not need a separator since they have a border. For other variants, a separator is recommended to improve the visual hierarchy.

Split

Create a split button group by adding two buttons separated by a ButtonGroupSeparator.

Input

Wrap an Input component with buttons.

Select

Pair with a Select component.

Create a split button group with a dropdown menu.

API Reference

Styled Component API

These props are added or materially changed by the installed styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Expand a prop to see named type definitions and framework-specific imports. Follow the Primitive and Runtime links for lower-level behavior props.

Button Group

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
orientation "horizontal" | "vertical" "horizontal"
Description
Selects the horizontal or vertical layout direction.
Classification
Styled variant

Changelog

View version history v1.1.2 5 releases

v1.1.2

  • In Astro, an attribute that you set on ButtonGroup and ButtonGroupText now wins over the component’s own default for the same attribute, such as role or aria-label.

v1.1.1

  • The default export in index.ts now has a name, ButtonGroupParts, so framework tools show a clear name.

v1.1.0

  • The component is now available for React as well as Astro. Its props and styles stay the same.

v1.0.2

  • The Tailwind variants now live in their own variants.ts file in the component folder.

v1.0.0

  • Initial release with starwind v1.12