Divider Component — Astro

Horizontal or vertical divider line with optional label

Divider Component

A simple divider for visually separating content. Supports horizontal (default) and vertical orientation, and an optional label (e.g. "OR") in the middle for horizontal dividers.

Add this component

The command below includes <strong>Divider</strong>—run it in your project directory to install this component (and the CSS if needed). No prompts.

Choose your package manager — click a tab to select, then copy the command.

npm pnpm yarn bun

Props

  • orientation (string, optional) - horizontal, vertical (default: horizontal)
  • label (string, optional) - Optional text shown in the middle (horizontal only)
  • class (string, optional) - Additional CSS classes

Basic Usage (horizontal)

Live Example

Content above

Content below

Usage

Full example for each framework (Astro, Vanilla, Svelte, Vue, React). Switch framework via View as or by clicking a Usage tab—both stay in sync.

Astro Vanilla Svelte Vue React

With Label

Use label to show text in the middle (e.g. "OR" between two options).

Live Example
astro astro
<Divider label="OR" />

Vertical

Use orientation="vertical" inside a flex row to separate items. The parent should have a defined height (e.g. min-height or height).

Live Example
Item 1 Item 2 Item 3
astro astro
<div style="display: flex; align-items: center; gap: var(--spacing-3); min-height: 3rem;">
  <span>Item 1</span>
  <Divider orientation="vertical" />
  <span>Item 2</span>
  <Divider orientation="vertical" />
  <span>Item 3</span>
</div>

Features

  • Accessible - role="separator" and aria-orientation; optional aria-label when label is set
  • Horizontal - Full-width line; optional label in the center
  • Vertical - Full-height line for use in flex layouts
  • Theme-aware - Uses --border and --text-dim

Other frameworks: Vanilla · Svelte · Vue · React