Separator
Visually or semantically separates content.
Usage
import {Separator} from "@/components/ui/separator";
<Separator />;Components
Separator
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | "horizontal" | "vertical" | "horizontal" | The separator orientation. |
decorative | boolean | true | If true, hides the separator from assistive technologies. When false, ARIA accessibility props are applied. |
asChild | boolean | false | Clone the first child and apply all separator props to it. |
baseClassName | string | - | Custom tailwind classes applied to the base separator. Takes precedence over className. |
className | string | - | Additional classes merged when baseClassName is not provided. |
Hooks
useSeparator
Backbone hook that returns platform-appropriate accessibility props for the separator. On web, integrates with React Aria.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
orientation | "horizontal" | "vertical" | "horizontal" | The separator orientation. |
decorative | boolean | true | If true, hides the separator from assistive technologies. |
Returns:
{
componentProps: React.ComponentProps<typeof View> | HTMLDivElement;
}| Property | Type | Description |
|---|---|---|
componentProps | React.ComponentProps<typeof View> | HTMLDivElement | Props to spread on the separator root element. |
Accessibility
- When
decorativeistrue(default), the separator is visually rendered but not exposed to assistive technologies. - When
decorativeisfalse, the component setsrole="separator",accessibilityRole="separator", andaria-orientation. - Web uses
useSeparatorto ensure correct semantics.
Styling
The separator uses Tailwind Variants:
- Base:
shrink-0 bg-border - Orientation variants:
- Horizontal:
h-px w-full - Vertical:
h-full w-px
- Horizontal:
Use baseClassName to override the base classes entirely, or className to merge additional classes.