---
title: Separator for Astro
description: "Astro dividers for visual grouping or a semantic content boundary."
seo:
    title: Separator for Astro | Shadcn & Tailwind CSS
related:
    - /components/field
    - /components/frame
sidebar:
    label: "Separator"
---

```astro
---
import { Separator } from "@/components/ui/separator"
---

<div class="flex w-full max-w-sm flex-col gap-4">
  <div>
    <h4 class="text-sm font-medium">Horizontal Separator</h4>
    <p class="text-muted-foreground text-sm">Divides sections horizontally</p>
  </div>
  <Separator />
  <div>
    <h4 class="text-sm font-medium">End of content</h4>
  </div>
</div>
```

## Installation

### Command

```sh
bunx --bun shadcn@latest add @gnostic/separator
```

### Manual

Complete the [Installation guide](/docs/installation) first. Then copy the component files below.

No extra packages are required.

#### src/components/ui/separator/index.ts

```ts
export { default as Separator } from "./separator.astro"
```

#### src/components/ui/separator/separator.astro

```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>
```

Component classes use the preset configured during project setup. Select the same preset in the docs before copying Manual source. To change installed component classes, edit or reinstall their source. See [Theming](/docs/theming) for details.


## Usage

```ts
import { Separator } from "@/components/ui/separator"
```

```astro
<Separator />
<Separator decorative={false} />
```

## Examples

```astro
---
import { Separator } from "@/components/ui/separator"
---

<div class="flex items-center gap-3 text-sm leading-none">
  <span>Account</span>
  <Separator orientation="vertical" />
  <span>Billing</span>
  <Separator orientation="vertical" />
  <span>Settings</span>
</div>
```

## 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](/r/separator.json) 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.
