Skip to content
WunderUI

Divider with Label

Free

Separate two alternatives with a line that carries a short word, a button or an icon.

npx wunderui-cli add divider-with-label

Playground

or continue with

Installation

bash
npx wunderui-cli add divider-with-label

Writes the source into your project with its dependencies and, on first use, the styles - see Installation.

Then import what you need:

tsx
import { DividerWithLabel } from "@/components/wunderui/divider-label"
import type { DividerWithLabelSize } from "@/components/wunderui/divider-label"

Then use it:

tsx
import { DividerWithLabel } from "@/components/ui/divider-with-label"

export function Choice() {
  return (
    <div className="w-96">
      <DividerWithLabel>or continue with</DividerWithLabel>
    </div>
  )
}

Expected result: You see one line across the full 384 px width, broken in the middle by the words or continue with in small muted text.

When to use

Use Divider with Label for

  • Telling people that the groups above and below are alternatives, such as a provider button and an email form
  • A break in a long list that carries its action, such as a Load more button on the line
  • A short phrase that leads from one option to the next, such as or pay with card

Use something else for

  • Separator for a plain line, horizontal or vertical, without any text on it
  • Heading for the start of a new section, which needs a real heading element for screen readers
  • Card for two options that each deserve their own surface instead of a line between them

Size

The default has a 14 px medium label and 12 px between label and lines. The small size has a 12 px regular label and 16 px of air, for a single word such as or.

or continue with

Content

The label is a word or two, or a small plain button, icon button or icon for an action that belongs to the break.

or continue with

Style

Solid lines separate two alternatives. Dashed lines make a lighter break.

or continue with

Semantics

With a label the two lines are hidden from assistive technology and the label is read as text. Without one the row is a single separator.

Without a label

or continue with

Spacing in layouts

The divider is full width and has no margin. In a column it takes the column's gap, 16 px above and below.

or

Behavior and motion

What the divider does with its layout, its label and the lines.

Layout
The row is a full-width flex container with the items centred. The two lines share the space the label leaves, so the label always sits in the middle and cannot move to the start or end.
Size
The default size has a 14 px medium label and 12 px between label and line. The small size has a 12 px regular label and 16 px of air, which suits one word.
Label
Anything that is not empty counts as a label: text, a button, an icon. Null, false, true or only spaces count as no label, and then the gap is 0 and the two lines meet.
Semantics
With a label the row has no role and the lines are hidden, so a screen reader reads the label as plain text. Without a label the row is announced as a separator.
Interactive label
A button or icon button on the line keeps its own focus stop and name, in page order. The divider adds no keyboard behaviour of its own.
Theme
The lines use the border token and the text the tertiary text token, so the divider follows the theme and dark mode. A button on the line keeps the colours of its own variant.
Motion
The divider has no state and no transition. A button on the line has the hover and press motion of the button itself.
Reduced motion
There is no animation in the divider to reduce. The button on the line follows the reduced motion rules of Button.

Anatomy

The parts of the divider, numbered in the figure. The lines are the Separator component, used twice.

or continue with
  • data-slot="divider-with-label"

    A full-width row of a line, a label and a second line, separating two groups such as two ways to sign in. A small size suits a short word like or, and the lines can be dashed.

  • data-slot="separator"

    Two decorative lines that stretch to fill the space on either side of the label. With no label the row itself becomes a single separator and the two lines meet in the middle.

  • Optional

    A word or two such as or, centred between the lines in muted text. It can also hold a small plain button, an icon button or an icon.

Best practices

  • Do

    Keep the label to one or two words that say how the groups relate: or, or continue with. Longer text squeezes the lines away.

  • Do

    Place it only between two alternatives, such as sign-in buttons above and an email form below. The label reads as a choice between what is above and what is below.

  • Do

    Use the small size for a one word label such as or, and the default size for a phrase such as or continue with.

  • Do

    Put a small plain Button or an IconButton on the line for an action that belongs to the break, such as Load more. Give an icon button an aria-label.

  • Do

    Use the same word as the buttons around it. If the buttons say Continue with, the label says or, not alternatively.

  • Don’t

    Don't use it as a section heading. The label is small, muted text with no heading role, so start a new section with a real heading.

  • Don’t

    Don't put it above the first or below the last block. It separates two blocks, so with only one side it points at nothing.

API reference

One table for the one part. DividerWithLabel also takes every prop of the div it renders, such as id and aria-label, and a role you pass replaces the one it sets.

A full-width row of a line, a label and a second line, separating two groups such as two ways to sign in. A small size suits a short word like or, and the lines can be dashed.

PropTypeDefaultDescription
childrenReactNode—The label between the two lines: a word or two, a small plain Button, an IconButton or an icon. Leave it out for a single separator.
size"default" | "sm""default" has a 14 px medium label and 12 px of air on each side. has a 12 px regular label and 16 px of air, for a single word.
dashedbooleanfalseDraws both lines as 1 px dashed borders instead of filled lines, for a lighter break.
classNamestring—Extra classes for the row, such as a vertical margin. The row is a full-width flex container.

Notes for AI

Give your coding assistant the Markdown reference instead of screenshots.

MCPget_component("divider-with-label")
Installnpx wunderui-cli add divider-with-label

The full library index for assistants is at /llms.txt.