Switcher
A component that allows the user to switch between different teams or accounts.
Example
Preview
API
Switcher
| Property | Type | Possible values | Default | Description |
|---|---|---|---|---|
| children | React.ReactNode | - | - | The content of the switcher (trigger and content components). |
| value | string | - | - | Optional controlled value for the selected item. |
| onValueChange | (value: string) => void | - | - | Optional callback function called when the selected value changes. |
| open | boolean | true, false | - | Controls the open state of the dropdown (controlled). |
| defaultOpen | boolean | true, false | false | Whether the dropdown is initially open (uncontrolled). |
| onOpenChange | (open: boolean) => void | - | - | Callback called when the open state changes. |
SwitcherTrigger
| Property | Type | Possible values | Default | Description |
|---|---|---|---|---|
| children | React.ReactNode | - | - | The trigger element that opens the switcher dropdown when clicked. |
| asChild | boolean | true, false | true | When true, merges with the immediate child element instead of rendering a button. |
SwitcherContent
| Property | Type | Possible values | Default | Description |
|---|---|---|---|---|
| children | React.ReactNode | - | - | The content to display inside the dropdown (groups, items, separators, footer). |
| align | ”start” | “center” | “end" | "start”, “center”, “end" | "center” | Alignment of the dropdown relative to the trigger element. |
| side | ”top” | “right” | “bottom” | “left" | "top”, “right”, “bottom”, “left" | "right” | Side where the dropdown should appear relative to the trigger element. |
SwitcherGroup
| Property | Type | Possible values | Default | Description |
|---|---|---|---|---|
| children | React.ReactNode | - | - | The items belonging to this group. |
| label | string | - | - | Optional label displayed as the group header. |
SwitcherItem
| Property | Type | Possible values | Default | Description |
|---|---|---|---|---|
| children | React.ReactNode | - | - | The content of the item (usually text label). |
| value | string | - | - | Optional value for the item. When provided, item becomes selectable. |
| onClick | () => void | - | - | Optional callback function called when the item is clicked. |
| icon | string | React.ReactNode | - | - | Optional icon to display. Can be an image URL (string) or React element. |
SwitcherFooter
| Property | Type | Possible values | Default | Description |
|---|---|---|---|---|
| children | React.ReactNode | - | - | The content of the footer item (usually text label). |
| onClick | () => void | - | - | Optional callback function called when the footer is clicked. |
| icon | React.ReactNode | - | - | Optional icon to display in the footer. |
SwitcherSeparator
This component has no props. It renders a visual separator between groups or sections.
Last updated on