# Divider with Label

A separator with a centered text label, e.g. for "or" between two sign-in options.

- Category: Core Elements
- Page: https://wunderui.com/components/divider-with-label
- Tier: Free

## Install

```bash
npx wunderui-cli add divider-with-label
```

## Import

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

## Minimal usage

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.

## Usage

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

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

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

- [Separator](https://wunderui.com/components/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](https://wunderui.com/components/card) for two options that each deserve their own surface instead of a line between them

## Behavior

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

- `DividerWithLabel`: 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.
- `Lines`: 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.
- `Label`: 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

### When to use

- Use a Divider with Label between two alternative ways to do the same thing, such as social sign-in and email. For a line without text, use Separator.

### 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.
- 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.
- Use the small size for a one word label such as or, and the default size for a phrase such as or continue with.
- 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.
- 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 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

### DividerWithLabel

| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode |  | 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. |
| className | string |  | Extra classes for the row, such as a vertical margin. The row is a full-width flex container. |
| dashed | boolean | false | Draws both lines as 1 px dashed borders instead of filled lines, for a lighter break. |
| size | "default" \| "sm" | "default" | `default` has a 14 px medium label and 12 px of air on each side. `sm` has a 12 px regular label and 16 px of air, for a single word. |

Also accepts React.HTMLAttributes attributes.

## Examples

### Size: a phrase in the default size, one word in the small one

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

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

### Content: text, a button, an icon button or an icon

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

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

### Style: solid or dashed

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

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

### Without a label: one separator, with a label: plain text between two hidden lines

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

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

### Spacing in layouts: sign-in options and a feed

```tsx
import { Button } from "@/components/ui/button"
import { DividerWithLabel } from "@/components/ui/divider-with-label"
import { Input } from "@/components/ui/input"

export function Example() {
  return (
    <div className="flex w-80 max-w-full flex-col gap-4">
      <Button variant="plain" className="w-full">
        Continue with GitHub
      </Button>
      <DividerWithLabel size="sm">or</DividerWithLabel>
      <Input type="email" aria-label="Email address" placeholder="info@wunderui.com" />
      <Button variant="gradient" className="w-full">
        Continue with email
      </Button>
    </div>
  )
}
```

## In context

### Create an account: a provider or an email address

The small divider with the word or tells people the two ways in are alternatives. The provider button sits above it, the email form below.

```tsx
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { DividerWithLabel } from "@/components/ui/divider-with-label"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"

export function Example() {
  return (
    <Card className="w-96 max-w-full">
      <CardHeader>
        <CardTitle>Create an account</CardTitle>
        <CardDescription>Use a provider or your email address.</CardDescription>
      </CardHeader>
      <CardContent className="flex flex-col gap-4">
        <Button variant="plain" className="w-full">
          Continue with GitHub
        </Button>
        <DividerWithLabel size="sm">or</DividerWithLabel>
        <div className="flex flex-col gap-2">
          <Label htmlFor="register-email">Email address</Label>
          <Input id="register-email" type="email" placeholder="info@wunderui.com" />
        </div>
        <Button variant="gradient" className="w-full">
          Continue with email
        </Button>
      </CardContent>
    </Card>
  )
}
```

### Activity feed: a button on the line loads more entries

Load more adds two entries each time. When the feed is complete the divider goes away, and Reset starts again with two.

```tsx
import { useState } from "react"
import { Button } from "@/components/ui/button"
import { DividerWithLabel } from "@/components/ui/divider-with-label"

const activity = [
  { who: "Nora Lindgren", what: "commented on Checkout redesign", when: "9:41 AM" },
  { who: "Daniel Okafor", what: "approved Design tokens v2", when: "9:12 AM" },
  { who: "Priya Raman", what: "opened Billing portal", when: "Yesterday" },
  { who: "Tomás Ferreira", what: "merged Invoice export", when: "Yesterday" },
  { who: "Maya Kessler", what: "archived Q3 campaign", when: "Mon" },
  { who: "Nora Lindgren", what: "assigned you Payment methods", when: "Mon" },
]

export function Example() {
  const [shown, setShown] = useState(2)

  return (
    <div className="flex w-96 max-w-full flex-col gap-4 text-sm">
      {activity.slice(0, shown).map((row) => (
        <div key={row.what}>
          <p className="text-foreground">
            <strong>{row.who}</strong> {row.what}
          </p>
          <p className="text-text-secondary">{row.when}</p>
        </div>
      ))}
      {shown < activity.length && (
        <DividerWithLabel>
          <Button variant="plain" size="sm" onClick={() => setShown(shown + 2)}>
            Load more
          </Button>
        </DividerWithLabel>
      )}
    </div>
  )
}
```

### Checkout: pay with a wallet or with a card

The phrase on the line leads from the quick option to the form. It uses the default size because it is more than one word.

```tsx
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { DividerWithLabel } from "@/components/ui/divider-with-label"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"

export function Example() {
  return (
    <Card className="w-96 max-w-full">
      <CardHeader>
        <CardTitle>Pay $69.98</CardTitle>
        <CardDescription>Team plan, billed monthly</CardDescription>
      </CardHeader>
      <CardContent className="flex flex-col gap-4">
        <Button variant="plain" className="w-full">
          Pay with wallet
        </Button>
        <DividerWithLabel>or pay with card</DividerWithLabel>
        <div className="flex flex-col gap-2">
          <Label htmlFor="checkout-name">Name on card</Label>
          <Input id="checkout-name" placeholder="Nora Lindgren" />
        </div>
        <Button variant="gradient" className="w-full">
          Pay $69.98
        </Button>
      </CardContent>
    </Card>
  )
}
```

## For AI agents

`get_component("divider-with-label")`

Hand your agent this page as Markdown or the WunderUI MCP server, not a screenshot.
