Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

Separator for Astro

Astro dividers for visual grouping or a semantic content boundary.

Horizontal Separator

Divides sections horizontally

End of content

Installation

bunx --bun shadcn@latest add @gnostic/separator
npx shadcn@latest add @gnostic/separator
pnpm dlx shadcn@latest add @gnostic/separator

Component classes: Default Gnostic.

Complete the Installation guide first. Then copy the component files below.

No extra packages are required.

Copy the files

src/components/ui/separator/index.ts
export { default as Separator } from "./separator.astro"
src/components/ui/separator/separator.astro
---
import type { HTMLAttributes } from "astro/types"

import { cn } from "cn"

type Props = HTMLAttributes<"div"> & {
  orientation?: "horizontal" | "vertical"
  decorative?: boolean
}

const {
  class: className,
  orientation = "horizontal",
  decorative = true,
  ...props
} = Astro.props
---

<div
  data-slot="separator"
  data-orientation={orientation}
  data-horizontal={orientation === "horizontal" ? "" : undefined}
  data-vertical={orientation === "vertical" ? "" : undefined}
  role={decorative ? "none" : "separator"}
  aria-orientation={decorative ? undefined : orientation}
  class={cn("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:not-[[class^='h-']]:not-[[class*='_h-']]:self-stretch", className)}
  {...props}
></div>

Usage

import { Separator } from "@/components/ui/separator"
<Separator />
<Separator decorative={false} />

Examples

Account
Billing
Settings

Notes

  • Use decorative={false} when the separator conveys structure to assistive technology.
  • Vertical separators stretch inside flex rows by default.

API Reference

Read the installed source for the complete prop types.

When to use Separator

Use Separator between related groups that need a visible boundary. Choose horizontal or vertical orientation to match the surrounding layout. Set the height of a vertical divider when its parent does not supply one.

Keyboard and behavior

Use decorative separators when the grouping is already clear from headings or landmarks. Reserve separator semantics for a boundary that adds meaning. A divider must not replace a useful section title.

Theme and layout

The line uses the shared border color. Check it on muted and card surfaces in both modes. Spacing around the line belongs to the parent layout.