ButtonGroup
A container that groups related buttons with shared borders and rounded corners.
The ButtonGroup component visually groups related buttons by removing inner borders and radius, relying on the container's overflow-hidden and rounded-md for clean outer corners. It supports horizontal and vertical orientations and includes a ButtonGroupText component for static label segments.
Preview
Installation
npx novaui-cli add button-groupImport
import { ButtonGroup, ButtonGroupText } from 'novaui-components'Basic Usage
Group related buttons together with a shared visual style:
import { ButtonGroup, ButtonGroupText } from 'novaui-components'
import { Button } from 'novaui-components'
export function BasicButtonGroup() {
return (
<ButtonGroup>
<Button variant="outline">Previous</Button>
<Button variant="outline">Next</Button>
</ButtonGroup>
)
}Orientation
Horizontal
The default orientation, grouping buttons side by side:
<ButtonGroup orientation="horizontal">
<Button variant="outline">Day</Button>
<Button variant="outline">Week</Button>
<Button variant="outline">Month</Button>
</ButtonGroup>Vertical
Stack buttons vertically with shared borders:
<ButtonGroup orientation="vertical">
<Button variant="outline">Top</Button>
<Button variant="outline">Middle</Button>
<Button variant="outline">Bottom</Button>
</ButtonGroup>With Text Segment
Use ButtonGroupText for a non-interactive label segment within the group:
<ButtonGroup>
<ButtonGroupText>Page</ButtonGroupText>
<Button variant="outline">1</Button>
<Button variant="outline">2</Button>
<Button variant="outline">3</Button>
</ButtonGroup>Multiple Variants
Combine different button variants within a group:
<ButtonGroup>
<Button variant="outline">Cancel</Button>
<Button>Save</Button>
</ButtonGroup>Props API
ButtonGroupProps
Extends React.ComponentPropsWithoutRef<typeof View> and VariantProps<typeof buttonGroupVariants>:
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | 'horizontal' | 'vertical' | 'horizontal' | Layout direction of the grouped buttons |
className | string | - | Additional CSS classes for the group container |
children | React.ReactNode | - | Button and ButtonGroupText children |
ButtonGroupTextProps
Extends React.ComponentPropsWithoutRef<typeof View>:
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | Additional CSS classes |
children | React.ReactNode | - | Label text content |
The container applies flex-row items-stretch overflow-hidden rounded-md and clones children with rounded-none and appropriate border removal (border-l-0 for horizontal, border-t-0 for vertical).
Best Practices
- Use for related actions: Group buttons that perform related operations (pagination, view modes, undo/redo)
- Keep groups small: 2-4 buttons per group works best for scannability
- Consistent variants: Use the same button variant within a group for visual consistency (except for primary action highlighting)
- Use ButtonGroupText sparingly: Label segments work well for context like "Page" or "Sort by"
Related Components
- Use
ToggleGroupwhen buttons represent toggleable states - Use individual
Buttoncomponents for standalone actions - Pair with
Separatorfor additional visual grouping in toolbars