Skip to content

Material 3

Components

Divider

Dividers are thin lines that group content in lists or other containers.

9:30
ContactsFavorites
AAli ConnorsMobile
SSandra AdamsWork
All contacts
BBritta HoltMobile
JJonas MeyerHome
MMina ParkMobile

Dividers are thin lines that group content in lists or other containers. Use them to group components visually, to create hierarchy, and to imply nested parent and child relationships.

To separate the items of a list or a menu, use their own dividers instead.

import { Divider } from '@material-web/react'

Basic divider

Put a Divider between the content it separates. In this example, a full-width divider separates the content of a card from its actions.

Glass & GraceSound Check: Making of Eye Rhymes
import { Button, Card, Divider } from '@material-web/react'

export default function Basic() {
  return (
    <Card variant="outlined" className="w-80">
      <div className="flex flex-col gap-space-50 p-space-200">
        <span className="text-title-md text-on-surface">Glass & Grace</span>
        <span className="text-body-md text-on-surface-variant">
          Sound Check: Making of Eye Rhymes
        </span>
      </div>
      <Divider />
      <div className="flex justify-end p-space-100">
        <Button variant="text">Read more</Button>
      </div>
    </Card>
  )
}

A divider comes in three variants. Set variant to full-width (the default), inset or middle-inset.

Full-width divider

Use a full-width divider to separate larger sections of unrelated content, such as the messages of an inbox in this example. It can go directly on a surface, or inside another component such as a card or a list.

Brunch this weekend?I'll be in your neighborhood on Saturday
Summer barbecueWish I could come, but I'm out of town
Concert ticketsThere are a couple of good shows next month
import { Card, Divider } from '@material-web/react'

const messages = [
  { title: 'Brunch this weekend?', preview: "I'll be in your neighborhood on Saturday" },
  { title: 'Summer barbecue', preview: "Wish I could come, but I'm out of town" },
  { title: 'Concert tickets', preview: 'There are a couple of good shows next month' },
]

export default function FullWidth() {
  return (
    <Card variant="outlined" className="w-80 py-space-100">
      {messages.map(({ title, preview }, index) => (
        <div key={title}>
          {index > 0 && <Divider />}
          <div className="flex flex-col px-space-200 py-space-150">
            <span className="truncate text-body-lg text-on-surface">{title}</span>
            <span className="truncate text-body-md text-on-surface-variant">{preview}</span>
          </div>
        </div>
      ))}
    </Card>
  )
}

Inset divider

An inset divider starts 16dp in from the leading edge. Use it to separate related items within a section, next to an anchoring element such as an icon or an avatar.

Brunch this weekend?I'll be in your neighborhood on Saturday
Summer barbecueWish I could come, but I'm out of town
Concert ticketsThere are a couple of good shows next month
import { Card, Divider, Icon } from '@material-web/react'

const messages = [
  { title: 'Brunch this weekend?', preview: "I'll be in your neighborhood on Saturday" },
  { title: 'Summer barbecue', preview: "Wish I could come, but I'm out of town" },
  { title: 'Concert tickets', preview: 'There are a couple of good shows next month' },
]

export default function Inset() {
  return (
    <Card variant="outlined" className="w-80 py-space-100">
      {messages.map(({ title, preview }, index) => (
        <div key={title}>
          {index > 0 && <Divider variant="inset" />}
          <div className="flex items-center gap-space-200 px-space-200 py-space-150">
            <span className="flex size-10 shrink-0 items-center justify-center rounded-shape-full bg-primary-container text-on-primary-container">
              <Icon name="person" className="icon-24" />
            </span>
            <div className="flex min-w-0 flex-col">
              <span className="truncate text-body-lg text-on-surface">{title}</span>
              <span className="truncate text-body-md text-on-surface-variant">{preview}</span>
            </div>
          </div>
        </div>
      ))}
    </Card>
  )
}

Middle-inset divider

A middle-inset divider is inset 16dp on both sides. Use it to separate elements in the middle of a layout, such as body text from a row of actions.

Dividers are one way to visually group components and create hierarchy. They can also be used to imply nested parent/child relationships.

import { Button, Card, Divider } from '@material-web/react'

export default function MiddleInset() {
  return (
    <Card variant="outlined" className="w-80">
      <p className="m-0 p-space-200 text-body-md text-on-surface">
        Dividers are one way to visually group components and create hierarchy. They can also be
        used to imply nested parent/child relationships.
      </p>
      <Divider variant="middle-inset" />
      <div className="flex gap-space-100 p-space-200">
        <Button variant="tonal" size="xs">
          Lists
        </Button>
        <Button variant="tonal" size="xs">
          Cards
        </Button>
        <Button variant="tonal" size="xs">
          Menus
        </Button>
      </div>
    </Card>
  )
}

Hierarchy

When you use full-width and inset dividers in one UI, put full-width dividers between sections of different content, and inset dividers between the nested items of a section.

Today
Brunch this weekend?I'll be in your neighborhood on Saturday
Summer barbecueWish I could come, but I'm out of town
Yesterday
Concert ticketsThere are a couple of good shows next month
import { Card, Divider, Icon } from '@material-web/react'

function Message({ title, preview }: { title: string; preview: string }) {
  return (
    <div className="flex items-center gap-space-200 px-space-200 py-space-150">
      <span className="flex size-10 shrink-0 items-center justify-center rounded-shape-full bg-primary-container text-on-primary-container">
        <Icon name="person" className="icon-24" />
      </span>
      <div className="flex min-w-0 flex-col">
        <span className="truncate text-body-lg text-on-surface">{title}</span>
        <span className="truncate text-body-md text-on-surface-variant">{preview}</span>
      </div>
    </div>
  )
}

export default function Hierarchy() {
  return (
    <Card variant="outlined" className="w-80 py-space-100">
      <div className="px-space-200 py-space-100 text-label-lg text-on-surface-variant">Today</div>
      <Message title="Brunch this weekend?" preview="I'll be in your neighborhood on Saturday" />
      <Divider variant="inset" />
      <Message title="Summer barbecue" preview="Wish I could come, but I'm out of town" />
      <Divider />
      <div className="px-space-200 py-space-100 text-label-lg text-on-surface-variant">
        Yesterday
      </div>
      <Message title="Concert tickets" preview="There are a couple of good shows next month" />
    </Card>
  )
}

Orientation

Set orientation="vertical" to separate content that is side by side. A vertical divider is a <div>, where a horizontal one is an <hr>.

by Selen ZeynepWhat buttons are artists pushing when they perform liveA vertical divider can be used to arrange content on a larger screen, such as separating paragraph text from video or imagery media.
import { Card, Divider, Icon } from '@material-web/react'

export default function Vertical() {
  return (
    <Card variant="outlined" className="w-full max-w-xl">
      <div className="flex gap-space-300 p-space-300">
        <div className="flex flex-1 items-center justify-center rounded-shape-md bg-primary-container text-on-primary-container">
          <Icon name="image" className="icon-48" />
        </div>
        <Divider orientation="vertical" />
        <div className="flex flex-1 flex-col gap-space-50">
          <span className="text-label-md text-on-surface-variant">by Selen Zeynep</span>
          <span className="text-title-md text-on-surface">
            What buttons are artists pushing when they perform live
          </span>
          <span className="text-body-md text-on-surface-variant">
            A vertical divider can be used to arrange content on a larger screen, such as separating
            paragraph text from video or imagery media.
          </span>
        </div>
      </div>
    </Card>
  )
}

On a vertical divider, inset adds 16dp at its top, and middle-inset adds 16dp at both ends.

Flex item

A divider is only as long as its container. It needs no prop in a flex or grid container, and it stretches even where the container centers its items.

OrientationLength
HorizontalThe width of its container, as a block or as a stretched item of a flex column or a grid
VerticalThe height of the flex or grid row it is in
128Posts
2.4KFollowers
310Following
import { Card, Divider } from '@material-web/react'

function Stat({ value, label }: { value: string; label: string }) {
  return (
    <div className="flex flex-col items-center px-space-300 py-space-200">
      <span className="text-title-lg text-on-surface">{value}</span>
      <span className="text-body-md text-on-surface-variant">{label}</span>
    </div>
  )
}

export default function FlexItem() {
  return (
    <Card variant="outlined" className="flex-row items-center">
      <Stat value="128" label="Posts" />
      <Divider orientation="vertical" />
      <Stat value="2.4K" label="Followers" />
      <Divider orientation="vertical" />
      <Stat value="310" label="Following" />
    </Card>
  )
}

Note: A vertical divider has no height in a block container, and a horizontal one has no width in a flex row.

In a list

A list holds only list items, and a divider is not one. To divide a list into groups, make each group a list of its own, with the divider between them, and name each list with an aria-label.

  • Inbox
  • Starred
  • Receipts
  • Travel
import { Card, Divider } from '@material-web/react'

export default function GroupedList() {
  return (
    <Card variant="outlined" className="w-64 py-space-100 text-body-lg text-on-surface">
      <ul aria-label="Mailboxes" className="m-0 list-none p-0">
        <li className="px-space-200 py-space-150">Inbox</li>
        <li className="px-space-200 py-space-150">Starred</li>
      </ul>
      <Divider />
      <ul aria-label="Folders" className="m-0 list-none p-0">
        <li className="px-space-200 py-space-150">Receipts</li>
        <li className="px-space-200 py-space-150">Travel</li>
      </ul>
    </Card>
  )
}

A List and a menu draw their own dividers. See their pages.

Icon grouping

Combine orientation="vertical" with variant="middle-inset" for a short divider between groups of controls in a row.

import { Card, Divider, Icon, IconButton } from '@material-web/react'

export default function IconGrouping() {
  return (
    <Card variant="outlined" className="flex-row">
      <div className="flex p-space-100">
        <IconButton aria-label="Align left">
          <Icon name="format_align_left" />
        </IconButton>
        <IconButton aria-label="Align center">
          <Icon name="format_align_center" />
        </IconButton>
        <IconButton aria-label="Align right">
          <Icon name="format_align_right" />
        </IconButton>
      </div>
      <Divider orientation="vertical" variant="middle-inset" />
      <div className="flex p-space-100">
        <IconButton aria-label="Bold">
          <Icon name="format_bold" />
        </IconButton>
        <IconButton aria-label="Italic">
          <Icon name="format_italic" />
        </IconButton>
      </div>
    </Card>
  )
}

Customization

Pass classes in className to restyle a divider. The line is a 1dp border, so change its color with a border color class, and add space around it with a margin. See Styling for the classes and the theme.

Subtotal$48.00
Shipping$4.00
Total$52.00
import { Card, Divider } from '@material-web/react'

export default function Custom() {
  return (
    <Card variant="outlined" className="w-80 p-space-200 text-body-lg">
      <div className="flex justify-between">
        <span>Subtotal</span>
        <span>$48.00</span>
      </div>
      <div className="flex justify-between">
        <span>Shipping</span>
        <span>$4.00</span>
      </div>
      <Divider className="my-space-150 border-primary" />
      <div className="flex justify-between text-title-md">
        <span>Total</span>
        <span>$52.00</span>
      </div>
    </Card>
  )
}

The className and style of a divider are plain values, not functions.