Installation
Install the dependencies
pnpm add cn class-variance-authority github:sveltery/baseCopy the component
Copy the following files into src/lib/components/ui/separator.
<script lang="ts">
import { Separator as Primitive } from '@sveltery/base/separator';
import { cn } from 'cn';
import type { SeparatorProps } from './types.js';
let { orientation = 'horizontal', class: classProp, ...props }: SeparatorProps = $props();
const className = $derived(cn('shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch', classProp));
</script>
<Primitive data-slot="separator" {orientation} class={className} {...props} />export type { SeparatorProps, SeparatorState } from '@sveltery/base/separator';export { default as Separator } from './Separator.svelte';
export type { SeparatorProps, SeparatorState } from './types.js';Update the import paths
Change the imports to match your project setup.
Usage
<script lang="ts">
import { Separator } from '$lib/components/ui/separator';
</script><Separator />API reference
Separator is styled on top of the Sveltery Base Separator primitive, which owns its behavior, focus handling and accessibility. See the Base UI Separator documentation for the behavior it ports.