--- title: Group description: A component for visually grouping a series of controls. --- ## Installation CLI Manual ```bash npx shadcn@latest add @coss/group ``` Install the following dependencies: ```bash npm install @base-ui/react ``` Copy and paste the following code into your project. Update the import paths to match your project setup. ## Usage ```tsx import { Button } from "@/components/ui/button" import { Group, GroupSeparator } from "@/components/ui/group" ``` ```tsx ``` ## 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. ```tsx showLineNumbers ``` ### 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. | Prop | Type | Default | | ------------- | ---------------------------- | -------------- | | `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | ```tsx ``` Nest multiple groups to create complex layouts with spacing. See the [nested groups](#nested-groups) example for more details. ```tsx ``` ### GroupSeparator The `GroupSeparator` component visually divides controls within a group. | Prop | Type | Default | | ------------- | ---------------------------- | ------------ | | `orientation` | `"horizontal" \| "vertical"` | `"vertical"` | ```tsx ``` **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. | Prop | Type | Default | | -------- | -------------------------- | ------- | | `render` | `React.ReactNode \| null` | `null` | ```tsx https:// ``` Use the `render` prop to render a custom component as the text, for example a label. ```tsx }> https:// ``` ## 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