Separator

A 1px hairline, horizontal or vertical.

Above the line

DocsPricing

Install

$ npx shadcn@latest add @nudgekit/separator

Or with no config: npx shadcn@latest add https://ui.nudgekit.app/r/separator.json

Usage

usage.tsx
import { Separator } from "@/components/ui/separator"

<Separator className="my-4" />
<Separator orientation="vertical" />

Do

  • Prefer spacing; add a line only when spacing is not enough.

Don't

  • Use thicker or coloured lines.

Code

What the CLI writes into your project. It is yours to change.

components/ui/separator.tsx
import * as React from "react";

import { cn } from "@/lib/utils";

function Separator({
  orientation = "horizontal",
  className,
  ...props
}: React.HTMLAttributes<HTMLDivElement> & { orientation?: "horizontal" | "vertical" }) {
  return (
    <div
      role="separator"
      aria-orientation={orientation}
      data-slot="separator"
      className={cn("shrink-0 bg-border", orientation === "horizontal" ? "h-px w-full" : "h-full w-px", className)}
      {...props}
    />
  );
}

export { Separator };