Search for a command to run...
Visually or semantically separates content.
npx shadcn@latest add @zaidan/separatorpnpx shadcn add @zaidan/separatoryarn dlx shadcn@latest add @zaidan/separatorbunx shadcn@latest add @zaidan/separatorCopy and paste the following code into your project.
1import type { PolymorphicProps } from "@kobalte/core/polymorphic";2import { Separator as SeparatorPrimitive, type SeparatorRootProps } from "@kobalte/core/separator";3import { type ComponentProps, mergeProps, splitProps, type ValidComponent } from "solid-js";4import { cn } from "~/lib/utils";5
6type SeparatorProps<T extends ValidComponent = "hr"> = PolymorphicProps<T, SeparatorRootProps<T>> &7 Pick<ComponentProps<T>, "class">;8
9const Separator = <T extends ValidComponent = "hr">(props: SeparatorProps<T>) => {10 const mergedProps = mergeProps({ orientation: "horizontal" } as const, props);11 const [local, others] = splitProps(mergedProps as SeparatorProps, ["class"]);12 return (13 <SeparatorPrimitive14 data-slot="separator"15 class={cn(16 "shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=vertical]:h-full data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px",17 local.class,18 )}19 {...others}20 />21 );22};23
24export { Separator, type SeparatorProps };Here are the source code of all the examples from the preview page:
import { Separator } from "~/components/ui/separator";function SeparatorHorizontal() { return ( <Example title="Horizontal"> <div class="flex flex-col gap-4 style-lyra:text-xs/relaxed text-sm"> <div class="flex flex-col gap-1"> <div class="font-medium leading-none">shadcn/ui</div> <div class="text-muted-foreground">The Foundation for your Design System</div> </div> <Separator /> <div> A set of beautifully designed components that you can customize, extend, and build on. </div> </div> </Example> );}import { Separator } from "~/components/ui/separator";function SeparatorVertical() { return ( <Example title="Vertical"> <div class="flex h-5 items-center gap-4 style-lyra:text-xs/relaxed text-sm"> <div>Blog</div> <Separator orientation="vertical" /> <div>Docs</div> <Separator orientation="vertical" /> <div>Source</div> </div> </Example> );}import { Separator } from "~/components/ui/separator";function SeparatorVerticalMenu() { return ( <Example title="Vertical Menu"> <div class="flex items-center gap-2 style-lyra:text-xs/relaxed text-sm md:gap-4"> <div class="flex flex-col gap-1"> <span class="font-medium">Settings</span> <span class="text-muted-foreground text-xs">Manage preferences</span> </div> <Separator orientation="vertical" /> <div class="flex flex-col gap-1"> <span class="font-medium">Account</span> <span class="text-muted-foreground text-xs">Profile & security</span> </div> <Separator orientation="vertical" /> <div class="flex flex-col gap-1"> <span class="font-medium">Help</span> <span class="text-muted-foreground text-xs">Support & docs</span> </div> </div> </Example> );}import { Separator } from "~/components/ui/separator";function SeparatorInList() { return ( <Example title="In List"> <div class="flex flex-col gap-2 style-lyra:text-xs/relaxed text-sm"> <dl class="flex items-center justify-between"> <dt>Item 1</dt> <dd class="text-muted-foreground">Value 1</dd> </dl> <Separator /> <dl class="flex items-center justify-between"> <dt>Item 2</dt> <dd class="text-muted-foreground">Value 2</dd> </dl> <Separator /> <dl class="flex items-center justify-between"> <dt>Item 3</dt> <dd class="text-muted-foreground">Value 3</dd> </dl> </div> </Example> );}