Skip to content

Material 3

Theme

Shape

The corner radius scale and the shape library.

Use a rounded-shape-<size> class to set one of the ten corner radii of the Material 3 shape scale, from none to full. The scale works with every side and corner of Tailwind's rounded-* utilities, and each radius is also a custom property. Use a shape-<name> class to cut an element to a shape of the shape library.

Corner scale

The theme's corners follow Material's corner radius scale: ten steps, each named for how round it is. Use a step as a class, rounded-shape-<size>, or as a custom property, such as var(--md-sys-shape-corner-medium).

0
rounded-shape-none
4
rounded-shape-xs
8
rounded-shape-sm
12
rounded-shape-md
16
rounded-shape-lg
20
rounded-shape-lg-inc
28
rounded-shape-xl
32
rounded-shape-xl-inc
48
rounded-shape-2xl
full
rounded-shape-full
ClassTokenRadius
rounded-shape-none--md-sys-shape-corner-none0
rounded-shape-xs--md-sys-shape-corner-extra-small4dp
rounded-shape-sm--md-sys-shape-corner-small8dp
rounded-shape-md--md-sys-shape-corner-medium12dp
rounded-shape-lg--md-sys-shape-corner-large16dp
rounded-shape-lg-inc--md-sys-shape-corner-large-increased20dp
rounded-shape-xl--md-sys-shape-corner-extra-large28dp
rounded-shape-xl-inc--md-sys-shape-corner-extra-large-increased32dp
rounded-shape-2xl--md-sys-shape-corner-extra-extra-large48dp
rounded-shape-full--md-sys-shape-corner-fullfull

One dp is one px. The full corner is a radius of 9999px, more than half of any box, so it rounds the ends of a box of any size.

A corner class is one of Tailwind's border radius utilities, and is used like any other:

  • Tailwind's radii: Tailwind's own radii, such as rounded-sm, rounded-md and rounded-lg, are unchanged. Use them next to the scale.
  • States: Add a state variant for another corner in a state, as in hover:rounded-shape-lg. To animate the change, add a transition preset, such as transition-shape-color.
  • Your own CSS: Apply a corner with Tailwind's @apply, as in @apply rounded-shape-lg, or use its custom property.
  • Nested corners: For a rounded element inside a padded one, Material subtracts the padding from the outer radius, as in calc(var(--md-sys-shape-corner-extra-large) - 8px).
  • Merged classes: tailwind-merge does not know the scale, and keeps both of two corner classes. To merge them, use the tv or the twMerge that @material-web/react exports, where the later class replaces the earlier one.

Sides and corners

Use the scale with any of Tailwind's rounded-* utilities: a side (rounded-t-shape-lg, rounded-e-shape-xl) or a single corner (rounded-tl-shape-2xl).

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

export default function ShapeSides() {
  const box = 'size-24 bg-tertiary-container'
  return (
    <>
      <div className={twMerge(box, 'rounded-t-shape-xl')} />
      <div className={twMerge(box, 'rounded-e-shape-xl')} />
      <div className={twMerge(box, 'rounded-b-shape-xl')} />
      <div className={twMerge(box, 'rounded-s-shape-xl')} />
      <div className={twMerge(box, 'rounded-tl-shape-2xl rounded-br-shape-2xl')} />
    </>
  )
}

The s and e sides are the start and the end of a line of text, and follow the text direction, as Tailwind's logical properties do.

Material uses different corners on one shape for closely grouped items, such as the inner corners of a split button.

Inherited corners

Use rounded-inherit to give an element its parent's corner radius. The element follows the parent's corner as it changes, in a state or during a transition.

ClassCornersUse
rounded-inheritAll fourAn overlay that must always match its parent's current corner
rounded-t-inheritThe top twoThe first part of a clipped container
rounded-b-inheritThe bottom twoThe last part of a clipped container

Fully round corners

Two classes round the ends of a box fully. Which to use depends on whether the corner changes.

ClassUse
rounded-shape-fullA box whose corners stay round
rounded-space-<n>-variableA box whose corners change to a smaller radius

Use rounded-space-<n>-variable on a one-line box padded with py-space-<n>-variable, with the same step of the spacing scale for both:

<button class="rounded-space-125-variable px-space-200 py-space-125-variable">Save</button>

The radius is half the box's height as a length, so the box is round at any density, and a transition from it to a smaller corner shows throughout. A transition from rounded-shape-full does not: the corner stays round until the transition's end.

The class takes a side or a corner too, as in rounded-s-space-125-variable.

Shape library

Use a shape-<name> class to cut an element to one of the shapes of Material's shape library. Each shape is a clip-path polygon that fills the element's box, so its edge stays sharp at any size or scale. To add a shape of your own, see New shapes.

shape-circle
shape-square
shape-slanted
shape-arch
shape-fan
shape-arrow
shape-semicircle
shape-oval
shape-pill
shape-triangle
shape-diamond
shape-clamshell
shape-pentagon
shape-gem
shape-very-sunny
shape-sunny
shape-4-sided-cookie
shape-6-sided-cookie
shape-7-sided-cookie
shape-9-sided-cookie
shape-12-sided-cookie
shape-ghost-ish
shape-4-leaf-clover
shape-8-leaf-clover
shape-burst
shape-soft-burst
shape-boom
shape-soft-boom
shape-flower
shape-puffy
shape-puffy-diamond
shape-pixel-circle
shape-pixel-triangle
shape-bun
shape-heart

The element is the shape's container: its background, its border and its children, such as an image, an icon or text, show only inside the shape.

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

const photo = `data:image/svg+xml,${encodeURIComponent(
  '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 160"><rect width="160" height="160" fill="#E8DEF8"/><circle cx="112" cy="52" r="22" fill="#FFD8E4"/><path d="M0 118 52 76 92 108 122 88 160 116V160H0Z" fill="#6750A4"/></svg>',
)}`

export default function ShapeContainers() {
  return (
    <>
      <img src={photo} alt="" className="size-32 object-cover shape-9-sided-cookie" />
      <div className="flex size-32 items-center justify-center bg-primary-container text-on-primary-container shape-sunny">
        <Icon name="favorite" className="icon-48" />
      </div>
      <div className="flex size-32 items-center justify-center bg-tertiary-container text-display-md text-on-tertiary-container shape-4-sided-cookie">
        A
      </div>
    </>
  )
}
  • Proportions: A shape stretches to the element's box. Give the element a square box, as with size-32 or aspect-square, to keep the shape's own proportions.
  • Images: Use Tailwind's object-cover on an image, so that the picture fills the shape without stretching.
  • Shadows and focus rings: The clip path also hides what the element draws outside the shape, such as a shadow or a focus ring. For a shadow that follows the shape, put Tailwind's drop-shadow-* on a parent.
  • Where to use: Material uses abstract shapes on imagery and decorative UI, such as photo crops and avatars, and advises using them sparingly.
  • Pointer: Only the shape takes clicks and hovers. A pointer over a corner cut away reaches what is behind the element.
  • States and breakpoints: Add a state variant or a breakpoint for another shape, as in hover:shape-sunny, or remove the shape with shape-none, as in md:shape-none. The shape changes at once, without a transition.
  • Merged classes: tailwind-merge does not know the shapes, and keeps both of two shape classes. To merge them, use the tv or the twMerge that @material-web/react exports. There a later shape or shape-none replaces an earlier one, and a turn of a shape and Tailwind's rotate-* replace each other.

Rotation

Use shape-rotate-<n> to turn a shape by a number of degrees, or animate-shape-spin to turn it slowly and continuously. The element's content turns back as far, so it stays upright.

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

const photo = `data:image/svg+xml,${encodeURIComponent(
  '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 160"><rect width="160" height="160" fill="#E8DEF8"/><circle cx="112" cy="52" r="22" fill="#FFD8E4"/><path d="M0 118 52 76 92 108 122 88 160 116V160H0Z" fill="#6750A4"/></svg>',
)}`

export default function ShapeRotation() {
  return (
    <>
      <div className="size-32 animate-shape-spin shape-9-sided-cookie">
        <img src={photo} alt="" className="size-full object-cover" />
      </div>
      <div className="flex size-32 shape-rotate-90 items-center justify-center bg-primary-container text-on-primary-container shape-triangle">
        <Icon name="music_note" className="icon-40" />
      </div>
    </>
  )
}
  • Content: Each child of the element turns back about its own middle. A single child that fills the element or sits in its middle stays in place, so wrap several children, or an image, in one.
  • Angles: Turn the other way with -shape-rotate-<n>, or by any angle with a value in brackets, as in shape-rotate-[0.1turn]. With animate-shape-spin, the shape spins from its shape-rotate-<n> angle.
  • Speed: The shape turns once every 20 seconds. Set another time with an arbitrary property, as in [animation-duration:10s], or stop the turn with Tailwind's animate-none.
  • Reduced motion: With prefers-reduced-motion, the shape holds still at its shape-rotate-<n> angle.
  • Tailwind's rotation: Tailwind's rotate-* turns the content with the shape. Use shape-rotate-<n> in its place.

Custom shapes

Every corner of the scale is a custom property, so your own CSS can set it after the import. A value set before the import is replaced by the theme's. A corner you set changes every class and every component that uses it:

@import 'tailwindcss';
@import '@material-web/tailwind';

:root {
  --md-sys-shape-corner-medium: 8px;
  --md-sys-shape-corner-extra-large: 20px;
}
Token and theme variableDefaultComponents that use it, such as
--md-sys-shape-corner-none
--radius-shape-none
0pxNone
--md-sys-shape-corner-extra-small
--radius-shape-xs
4pxSnackbar, text field, plain tooltip, menu item
--md-sys-shape-corner-small
--radius-shape-sm
8pxChip
--md-sys-shape-corner-medium
--radius-shape-md
12pxCard, rich tooltip
--md-sys-shape-corner-large
--radius-shape-lg
16pxMenu, FAB, side sheet
--md-sys-shape-corner-large-increased
--radius-shape-lg-inc
20pxMedium FAB
--md-sys-shape-corner-extra-large
--radius-shape-xl
28pxDialog, bottom sheet, large FAB
--md-sys-shape-corner-extra-large-increased
--radius-shape-xl-inc
32pxNone
--md-sys-shape-corner-extra-extra-large
--radius-shape-2xl
48pxNone
--md-sys-shape-corner-full
--radius-shape-full
9999pxFloating toolbar, a day of a calendar

The fully round corner of a padded box is a theme variable too, one for each step of the spacing scale:

Theme variableStepsDefault
--radius-space-<n>-variable0, 25, 50, 75, 100, 125, 150, 175, 200, 250, 300, 400, 450, 500, 600, 700, 800, 900Half a line of text and the step's density padding
  • Theme variables: Under each token is its Tailwind theme variable, which gives the token its classes. In your own CSS, read the token, as in var(--md-sys-shape-corner-medium): a theme variable has the root's value, and does not follow a token set on an element.
  • Fully round corners: Use rounded-space-<n>-variable as a class, or with Tailwind's @apply. Read as a variable, it has the root's line height and density.
  • One part of the page: Set a token on an element, in place of the root, to change the corners inside it only.
  • One component: Pass a corner class in the component's className, as in <Card className="rounded-shape-xl">.
  • Round buttons: A round Button, IconButton, ButtonGroup or SplitButton takes its corner from its padding, as a fully round corner, so the full corner's token does not change it. For a squarer Button or IconButton, set its shape to square, or pass a corner class in its className.
  • Large corners: Material cautions against large or full corners on information-dense components, such as cards.

New shapes

Each shape of the shape library is a theme variable in the --shape-* namespace. Define one in @theme to add a shape, which gets its own shape-<name> class:

@import 'tailwindcss';
@import '@material-web/tailwind';

@theme {
  --shape-ticket: polygon(
    0 0,
    100% 0,
    100% 35%,
    95% 50%,
    100% 65%,
    100% 100%,
    0 100%,
    0 65%,
    5% 50%,
    0 35%
  );
}
<div class="shape-ticket h-24 w-64 bg-tertiary-container">...</div>
  • The value: A shape is any clip-path value. The points of a polygon(), in percent of the element's box, stretch with it as the library's shapes do. circle(), ellipse() and inset() work as well, and shape() draws curves in percent in the browsers that support it.
  • Library shapes: A variable named for a shape of the library, such as --shape-circle, replaces that shape. To leave out every shape of the library, set --shape-*: initial first, as when overriding a namespace.
  • Classes: A shape's class works like the library's, with state variants, shape-rotate-<n> and animate-shape-spin.