DividerDemo
import { Divider } from '@/components/ui/divider'
export function DividerDemo() {
return (
<div className='flex w-3/4 flex-wrap items-center gap-4'>
<Divider />
</div>
)
}
Installation
- Install the following dependencies
pnpm add @radix-ui/react-separator- Copy and paste the following code into your project
src/components/ui/divider.tsx
'use client'
import * as React from 'react'
import * as SeparatorPrimitive from '@radix-ui/react-separator'
import { cn } from '@/lib/utils'
function Divider({
className,
orientation = 'horizontal',
decorative = true,
...props
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
return (
<SeparatorPrimitive.Root
data-slot='separator'
decorative={decorative}
orientation={orientation}
className={cn(
'shrink-0 bg-outline-variant data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px',
className,
)}
{...props}
/>
)
}
export { Divider }
Usage
import { Divider } from '@/components/ui/divider'<Divider />API Reference
Divider
| Prop | type | default |
|---|---|---|
| orientation | horizontal | vertical | horizontal |
| decorative | boolean | true |
| asChild | boolean | false |