8.7k

Group

A component for visually grouping a series of controls.

Installation

pnpm dlx shadcn@latest add @coss/group

Usage

import { Button } from "@/components/ui/button"
import { Group, GroupSeparator } from "@/components/ui/group"
<Group>
  <Button>Button</Button>
  <GroupSeparator />
  <Button>Button</Button>
</Group>

Examples

With Input

Small Size

Large Size

With Disabled Button

With Default Buttons

With Start Labeled Text

With End Text

Vertical

Nested Groups

With Popup

With Input Group

With Menu

With Select

Accessibility

  • The Group component has the role attribute set to group.
  • Use Tab to navigate between the controls in the group.
  • Use aria-label or aria-labelledby to label the group.
<Group aria-label="Media controls">
  <Button variant="outline">Play</Button>
  <GroupSeparator />
  <Button variant="outline">Pause</Button>
</Group>

Group vs ToggleGroup

  • Use the Group component when you want to group controls that perform an action.
  • Use the ToggleGroup component when you want to group controls that toggle a state.

API Reference

Group

The Group component is a container that visually groups a series of related controls together with consistent styling.

<Group>
  <Button>Button 1</Button>
  <GroupSeparator />
  <Button>Button 2</Button>
</Group>

Nest multiple groups to create complex layouts with spacing. See the nested groups example for more details.

<Group>
  <Group>
    <Button>1</Button>
    <GroupSeparator />
    <Button>2</Button>
  </Group>
  <Group>
    <Button>Previous</Button>
    <GroupSeparator />
    <Button>Next</Button>
  </Group>
</Group>

GroupSeparator

The GroupSeparator component visually divides controls within a group.

<Group>
  <Button>Button 1</Button>
  <GroupSeparator />
  <Button>Button 2</Button>
</Group>

Note: Unlike shadcn's ButtonGroup, GroupSeparator is required between all controls, including outline buttons. This ensures consistent visual hierarchy and focus states.

GroupText

Use this component to display text within a group, such as labels or prefixes.

<Group>
  <GroupText>https://</GroupText>
  <GroupSeparator />
  <Input placeholder="example.com" />
</Group>

Use the render prop to render a custom component as the text, for example a label.

<Group>
  <GroupText render={<Label htmlFor="domain" aria-label="Domain" />}>
    https://
  </GroupText>
  <GroupSeparator />
  <Input id="domain" placeholder="example.com" />
</Group>

Comparing with shadcn

If you're already familiar with shadcn's ButtonGroup, this guide highlights the small differences and similarities so you can get started with coss ui quickly.

Quick Checklist

  • Prefer Group* component names; ButtonGroup* remain for compatibility
  • GroupSeparator is always required between controls, including outline buttons (unlike shadcn where separators are optional for outline buttons). This ensures consistent focus state handling and better accessibility
  • If you used asChild on ButtonGroupText, switch to the render prop for custom components

coss.com ui

Built by and for the team of Cal.com, Inc. — the leading commercial open source company (“coss”).