Choose a setup
For a React app with Tailwind CSS.
- React componentsMaterial 3 components, ready to use.Included
- Tailwind classesEvery design token as a class, for your own markup.Included
- CSS custom propertiesEvery design token as a variable, for your own CSS.Included
RequiresReact 19Tailwind CSS v4
Install the library
Both setups need Tailwind CSS v4 in your project. To add it, follow Tailwind's installation guide.
Install the components. The theme, @material-web/tailwind, is installed with them.
npm install @material-web/reactBeta. Both libraries are in beta, at version 0.1.1-beta.0. Their APIs may change between releases until the first stable version.
Load the styles and fonts
Import the library's stylesheet after Tailwind's. It adds the theme, the components' styles and the state variants to your build, and needs no @source.
@import 'tailwindcss';
@import '@material-web/react';Import Roboto and Material Symbols Outlined from Google Fonts at the top of your CSS, above any other import:
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200');To use other fonts, see Typography.
Use the library
Import the components you need. Style around them with the classes of the theme, next to Tailwind's own.
import { Card, Icon, IconButton, Slider } from '@material-web/react'
export default function First() {
return (
<Card className="w-80 gap-space-200 p-space-200 icon-filled">
<div className="grid h-40 place-items-center rounded-shape-lg bg-tertiary-container text-on-tertiary-container">
<Icon name="album" className="icon-96" />
</div>
<div className="px-space-100">
<div className="text-title-lg">Eye Rhymes</div>
<div className="text-on-surface-variant">Glass & Grace</div>
</div>
<Slider aria-label="Position" defaultValue={35} />
<div className="flex items-center justify-center gap-space-100">
<IconButton aria-label="Previous">
<Icon name="skip_previous" />
</IconButton>
<IconButton
variant="filled"
size="m"
width="wide"
aria-label="Play"
isSelectable
defaultSelected
>
{({ isSelected }) => <Icon name={isSelected ? 'pause' : 'play_arrow'} />}
</IconButton>
<IconButton aria-label="Next">
<Icon name="skip_next" />
</IconButton>
</div>
</Card>
)
}Tailwind theme
@material-web/tailwind is installed with @material-web/react. Install it alone to use its classes in your own markup or components, in any framework.
| Tokens | Utilities |
|---|---|
| Color | Color roles for the light and dark schemes at every contrast level. The tonal palettes are a separate import. |
| Typography | The type scale, where each style sets its size, line height, tracking and weight, with the typefaces and font weights. |
| Shape | The corner radius scale, for all corners or for a single side or corner, and the shape library. |
| Spacing | The spacing scale, for every spacing utility, next to Tailwind's own scale. |
| Elevation | The elevation levels, as shadows. |
| Motion | Easings, durations and springs, with transition presets. |
| State | State layer opacities, disabled opacities and focus rings. |
| Layout | Breakpoints for the window size, the stacking order and the scrollbar. |
| Density | Spacing that adjusts to the density level of an element or its container. |
| Accessibility | Touch targets, forced colors utilities and raised contrast variants. |
In your own CSS, use any token as a custom property, named as in the Material 3 spec: var(--md-sys-color-primary), var(--md-sys-shape-corner-medium), var(--md-sys-motion-easing-emphasized).
To change the tokens, such as the colors, the typefaces or the corners, see Styling.
Global styles
Neither library includes a CSS reset, so the existing styles of your page are not changed. Tailwind's own reset, Preflight, comes with @import 'tailwindcss'. The following styles are the only ones that apply to the whole page:
- Color scheme: The theme sets
color-schemeon the root element and on any element with adata-themeattribute, so that the browser's own controls match the light or dark theme. The page follows the system's scheme unless you set one. See Color. - Scrollbars: The theme styles the scrollbar of the page and of every scroll container as a 4dp thumb with no track. Add the
scrollbar-hiddenclass to an element to hide its scrollbar. See Layout.
Neither library sets the color or the typeface of the page. Add the page's color roles, its typeface and its type style to the body:
<body class="bg-surface font-plain text-body-lg text-on-surface"></body>