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).
rounded-shape-nonerounded-shape-xsrounded-shape-smrounded-shape-mdrounded-shape-lgrounded-shape-lg-incrounded-shape-xlrounded-shape-xl-incrounded-shape-2xlrounded-shape-full| Class | Token | Radius |
|---|---|---|
rounded-shape-none | --md-sys-shape-corner-none | 0 |
rounded-shape-xs | --md-sys-shape-corner-extra-small | 4dp |
rounded-shape-sm | --md-sys-shape-corner-small | 8dp |
rounded-shape-md | --md-sys-shape-corner-medium | 12dp |
rounded-shape-lg | --md-sys-shape-corner-large | 16dp |
rounded-shape-lg-inc | --md-sys-shape-corner-large-increased | 20dp |
rounded-shape-xl | --md-sys-shape-corner-extra-large | 28dp |
rounded-shape-xl-inc | --md-sys-shape-corner-extra-large-increased | 32dp |
rounded-shape-2xl | --md-sys-shape-corner-extra-extra-large | 48dp |
rounded-shape-full | --md-sys-shape-corner-full | full |
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-mdandrounded-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 astransition-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
tvor thetwMergethat@material-web/reactexports, 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.
| Class | Corners | Use |
|---|---|---|
rounded-inherit | All four | An overlay that must always match its parent's current corner |
rounded-t-inherit | The top two | The first part of a clipped container |
rounded-b-inherit | The bottom two | The 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.
| Class | Use |
|---|---|
rounded-shape-full | A box whose corners stay round |
rounded-space-<n>-variable | A 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-circleshape-squareshape-slantedshape-archshape-fanshape-arrowshape-semicircleshape-ovalshape-pillshape-triangleshape-diamondshape-clamshellshape-pentagonshape-gemshape-very-sunnyshape-sunnyshape-4-sided-cookieshape-6-sided-cookieshape-7-sided-cookieshape-9-sided-cookieshape-12-sided-cookieshape-ghost-ishshape-4-leaf-clovershape-8-leaf-clovershape-burstshape-soft-burstshape-boomshape-soft-boomshape-flowershape-puffyshape-puffy-diamondshape-pixel-circleshape-pixel-triangleshape-bunshape-heartThe 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-32oraspect-square, to keep the shape's own proportions. - Images: Use Tailwind's
object-coveron 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 withshape-none, as inmd: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
tvor thetwMergethat@material-web/reactexports. There a later shape orshape-nonereplaces an earlier one, and a turn of a shape and Tailwind'srotate-*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 inshape-rotate-[0.1turn]. Withanimate-shape-spin, the shape spins from itsshape-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'sanimate-none. - Reduced motion: With
prefers-reduced-motion, the shape holds still at itsshape-rotate-<n>angle. - Tailwind's rotation: Tailwind's
rotate-*turns the content with the shape. Useshape-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 variable | Default | Components that use it, such as |
|---|---|---|
--md-sys-shape-corner-none--radius-shape-none | 0px | None |
--md-sys-shape-corner-extra-small--radius-shape-xs | 4px | Snackbar, text field, plain tooltip, menu item |
--md-sys-shape-corner-small--radius-shape-sm | 8px | Chip |
--md-sys-shape-corner-medium--radius-shape-md | 12px | Card, rich tooltip |
--md-sys-shape-corner-large--radius-shape-lg | 16px | Menu, FAB, side sheet |
--md-sys-shape-corner-large-increased--radius-shape-lg-inc | 20px | Medium FAB |
--md-sys-shape-corner-extra-large--radius-shape-xl | 28px | Dialog, bottom sheet, large FAB |
--md-sys-shape-corner-extra-large-increased--radius-shape-xl-inc | 32px | None |
--md-sys-shape-corner-extra-extra-large--radius-shape-2xl | 48px | None |
--md-sys-shape-corner-full--radius-shape-full | 9999px | Floating 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 variable | Steps | Default |
|---|---|---|
--radius-space-<n>-variable | 0, 25, 50, 75, 100, 125, 150, 175, 200, 250, 300, 400, 450, 500, 600, 700, 800, 900 | Half 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>-variableas 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,ButtonGrouporSplitButtontakes its corner from its padding, as a fully round corner, so the full corner's token does not change it. For a squarerButtonorIconButton, set itsshapetosquare, or pass a corner class in itsclassName. - 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-pathvalue. The points of apolygon(), in percent of the element's box, stretch with it as the library's shapes do.circle(),ellipse()andinset()work as well, andshape()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-*: initialfirst, as when overriding a namespace. - Classes: A shape's class works like the library's, with state variants,
shape-rotate-<n>andanimate-shape-spin.