All contacts
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.
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.
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.
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.
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>.
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.
| Orientation | Length |
|---|---|
| Horizontal | The width of its container, as a block or as a stretched item of a flex column or a grid |
| Vertical | The height of the flex or grid row it is in |
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.
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.
Interaction and style
- Color contrast: Material treats dividers as decorative elements, which have no contrast minimum.
Labeling elements
- A divider has the
separatorrole. To name it, setaria-labeloraria-labelledby. - A vertical divider reports its orientation with
aria-orientation. - A divider takes no
aria-hidden: it is always exposed as a separator.
variant'full-width' | 'inset' | 'middle-inset'Default'full-width'The divider can be used in two ways:
- Full width
- Inset
full-width: Use full-width dividers to separate larger sections of unrelated content. They can be used directly on a surface or inside other components like cards or lists. Full-width dividers can also separate interactive areas from non-interactive areas.inset: Use inset dividers to separate related content within a section. Inset dividers separate related content, such as emails in a list. They should be used with anchoring elements such as icons or avatars, and align with the leading edge of the screen.middle-inset: Inset dividers can be placed in the middle of a layout to separate elements such as body text from selection chips
If dividers are used both ways in a UI, they must reinforce the hierarchy of information within different sections.
To separate a different kind of content, use a full-width divider
To separate nested content items, use inset dividers
Props of Divider (12)
classNamestringDefault'react-aria-Separator'The CSS className for the element.
orientation'horizontal' | 'vertical'Default'horizontal'The orientation of the separator.
elementTypestringThe HTML element type that will be used to render the separator.
idstringThe element's unique identifier. See MDN.
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.
styleCSSPropertiesThe inline style for the element.
slotstring | nullA slot name for the component. Slots allow the component to receive props from a parent component. An explicit
nullvalue indicates that the local props completely override all props received from a parent.renderDOMRenderFunction<'div' | 'hr', undefined>Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components.
Requirements:
- You must render the expected element type (e.g. if
<button>is expected, you cannot render an<a>). - Only a single root DOM element can be rendered (no fragments).
- You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate.
- You must render the expected element type (e.g. if
refRef<HTMLElement>
Divider also takes the 70 attributes and events of the element it renders.