Separator
Visually or semantically separates content.
npx shadcn@latest add @velaui/separatorpnpm dlx velaui add @velaui/separatoryarn dlx shadcn@latest add @velaui/separatorbunx --bun shadcn@latest add @velaui/separatorveni add separatorInstalls the copy of vela-ui that veni-builder serves to Venizia apps; veni-builder serves the Radix UI copy only, so this tab exists for that base alone.
npx shadcn@latest add @velaui/separatorpnpm dlx velaui add @velaui/separatoryarn dlx shadcn@latest add @velaui/separatorbunx --bun shadcn@latest add @velaui/separatorExamples
- Default
- Dashed light
- Bold section
- Dashed vertical bold
- Light vertical
Usage
Props
| Prop | Type | Default |
|---|---|---|
decorative | boolean | true |
emphasis | "high" | "light" | — |
orientation | "horizontal" | "vertical" | "horizontal" |
thickness | "default" | "bold" | — |
variant | "solid" | "dash" | — |
Takes these and every prop of SeparatorProps.
| Prop | Type | Default |
|---|---|---|
emphasis | "high" | "light" | — |
orientation | import("/app/node_modules/.bun/@base-ui+react@1.6.0+df7f6a806acd27ca/node_modules/@base-ui/react/index").Orientation | "horizontal" |
thickness | "default" | "bold" | — |
variant | "solid" | "dash" | — |
Takes these and every prop of SeparatorProps.
Dependencies
- npm
class-variance-authority@0.7.1radix-ui@1.6.0- Installs with it
- nothing else
- npm
@base-ui/react@1.6.0class-variance-authority@0.7.1- Installs with it
- nothing else
Source
components/ui/separator.tsx
/* eslint-disable react-refresh/only-export-components */
import * as React from "react";
import { Separator as SeparatorPrimitive } from "radix-ui";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
const separatorVariants = cva(
[
// The line itself is a border, not a fill — that is what lets `dash` exist.
// The box collapses on its own axis so the border width IS the thickness.
"shrink-0",
"data-horizontal:h-0 data-horizontal:w-full",
"data-vertical:w-0 data-vertical:self-stretch",
].join(" "),
{
variants: {
variant: {
solid: "border-solid",
dash: "border-dashed",
},
emphasis: {
high: "border-border-active",
light: "border-border-default",
},
thickness: {
default: "data-horizontal:border-t data-vertical:border-l",
bold: "data-horizontal:border-t-2 data-vertical:border-l-2",
},
},
defaultVariants: {
variant: "solid",
emphasis: "high",
thickness: "default",
},
},
);
export type SeparatorProps = React.ComponentProps<typeof SeparatorPrimitive.Root> &
VariantProps<typeof separatorVariants>;
function Separator({
className,
orientation = "horizontal",
decorative = true,
variant,
emphasis,
thickness,
...props
}: SeparatorProps) {
return (
<SeparatorPrimitive.Root
data-slot="separator"
decorative={decorative}
orientation={orientation}
className={cn(
separatorVariants({ variant, emphasis, thickness }),
className,
)}
{...props}
/>
);
}
export { Separator, separatorVariants };components/ui/separator.tsx
/* eslint-disable react-refresh/only-export-components */
import { Separator as SeparatorPrimitive } from "@base-ui/react/separator";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
const separatorVariants = cva(
[
// The line itself is a border, not a fill — that is what lets `dash` exist.
// The box collapses on its own axis so the border width IS the thickness.
"shrink-0",
"data-horizontal:h-0 data-horizontal:w-full",
"data-vertical:w-0 data-vertical:self-stretch",
].join(" "),
{
variants: {
variant: {
solid: "border-solid",
dash: "border-dashed",
},
emphasis: {
high: "border-border-active",
light: "border-border-default",
},
thickness: {
default: "data-horizontal:border-t data-vertical:border-l",
bold: "data-horizontal:border-t-2 data-vertical:border-l-2",
},
},
defaultVariants: {
variant: "solid",
emphasis: "high",
thickness: "default",
},
},
);
export type SeparatorProps = SeparatorPrimitive.Props &
VariantProps<typeof separatorVariants>;
function Separator({
className,
orientation = "horizontal",
variant,
emphasis,
thickness,
...props
}: SeparatorProps) {
return (
<SeparatorPrimitive
data-slot="separator"
orientation={orientation}
className={cn(
separatorVariants({ variant, emphasis, thickness }),
className,
)}
{...props}
/>
);
}
export { Separator, separatorVariants };