Group
A layout component that groups related form elements together.
Made by eblairmckeeNote: This component is deprecated and will no longer be maintained. Use InputGroup/ButtonGroup/Field component instead.
Loading component...
Installation
Usage
import { Group } from "@/components/ui/group"import { Group } from "@/components/ui/group"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
export function GroupExample() {
return (
<Group>
<Input placeholder="Enter value..." />
<Select defaultValue="option1">
<SelectTrigger className="w-[120px]">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="option1">Option 1</SelectItem>
<SelectItem value="option2">Option 2</SelectItem>
<SelectItem value="option3">Option 3</SelectItem>
</SelectContent>
</Select>
<Button>Submit</Button>
</Group>
)
}Examples
Basic Group
Loading component...
Attached Group
Loading component...
API Reference
Group
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | - | The form elements to group together |
| className | string | - | Additional CSS classes to apply to the group container |
| attached | boolean | false | Whether to visually connect the grouped elements |
Usage with useGroup hook
Components within a Group can access group context using the useGroup hook:
import { useGroup } from "@/components/ui/group"
function MyCustomInput() {
const { position, attached } = useGroup()
// position will be 'first', 'middle', 'last', or undefined
// attached indicates if the group is in attached mode
}When to use
- Form workflows: Group related inputs, selects, and buttons in forms
- Search interfaces: Combine search input with filters and action buttons
- Toolbar layouts: Group related action buttons together
- Data entry: Combine inputs with associated controls like dropdowns or buttons
Best Practices
- Use
attached={true}when you want elements to visually connect as a single unit - Use the default unattached mode when elements are related but should remain visually separate
- Keep groups to 2-4 elements for optimal user experience
- Ensure proper spacing and alignment within grouped elements
Credits
- Inspired by button groups and form layouts from modern design systems
- Built specifically for the Redpanda UI Registry
Built by malinskibeniamin. The source code is available on GitHub.