Skip to Content

Hairline

Hairline rule component: a 1px line in the border color whose ends fade out, for the line between two sections of a page, with a plain option for a rule inside a frame. Built on the stock Separator.

Installation

pnpm dlx shadcn@latest add @01orbital/hairline

Usage

import { Hairline } from "@/components/hairline/hairline"

// The copy: change text here, not in the markup.
const COPY = {
  first: "Blocks that read like a studio made them.",
  second: "Scenes and orbs for the quiet parts of a page.",
  rowOne: "Studio",
  rowTwo: "Scenes",
} as const

/** Hairline with faded ends between two lines of copy, then a plain one inside a frame. */
export default function HairlineDemo() {
  return (
    <div className="grid w-full max-w-2xl gap-10">
      <div>
        <p className="py-8 text-lg/7 text-foreground">{COPY.first}</p>
        <Hairline />
        <p className="py-8 text-lg/7 text-foreground">{COPY.second}</p>
      </div>
      <div className="mx-auto w-full max-w-xs rounded-sm border text-sm/6 text-foreground">
        <p className="px-4 py-3">{COPY.rowOne}</p>
        <Hairline fade="none" />
        <p className="px-4 py-3">{COPY.rowTwo}</p>
      </div>
    </div>
  )
}

This example installs with everything it uses:

pnpm dlx shadcn@latest add @01orbital/hairline-demo

API reference

A 1px rule in the border color whose ends dissolve: the line between two sections of a page. It is the stock Separator underneath, so it takes orientation and className the same way.

fade="ends" (the default) paints the line as a gradient, transparent at each end and the border color from 10% to 90%. fade="none" is a plain line. decorative (the default) hides it from assistive technology, since two sections are already separate landmarks; pass decorative={false} for a separator that means something, such as one between groups in a list. It carries no margin: leave the space around it to the layout, as with any rule.

Prop

Type

It also accepts the props of the Base UI part it wraps, and the HTML attributes of the element it renders.

Dependencies

npm: class-variance-authority, cn. The CLI installs them for you.

Requires these pieces. The CLI adds each one that is missing and won't replace a file you already have unless you choose to:

The shadcn parts here are their Base UI versions, and this piece uses Base UI's API. A Radix version you already have won't work with it.

Used in blocks

8 blocks are built with Hairline:

Last updated on