Material Design 3 expressive components for the web: as plain JavaScript, as web components, and as React, Vue, Svelte and Solid components. Written in TypeScript, with zero dependencies.
Material Design 3 components for the web: as web components, as React, Vue, Svelte and Solid components, and as plain JavaScript. Written in TypeScript, with zero dependencies.
Documentation, live playgrounds and examples: md3.io
<form>
<m-text-field name="email" type="email" label="Email" required></m-text-field>
<m-switch name="news" checked>Newsletter</m-switch>
<m-button type="submit">Sign up</m-button>
</form>
Once the elements are registered (below), these controls take part in the form as native ones do: its value, reset and validation.
material/components/listbox and material/components/bottom-app-bar-toolbar ship only at their own subpaths. Import their styles explicitly.material installs nothing else. React, Vue, Svelte and Solid are optional peers: material uses the one your app has.npm install material
React, Vue, Svelte and Solid are optional peer dependencies: material uses the one your app has and installs none of them.
| Way | Import from | Good for |
|---|---|---|
| Web components | material/elements | Plain HTML, server templates, Angular, any framework |
| React | material/react | React 18 and 19, Next.js |
| Vue | material/vue | Vue 3, Nuxt |
| Svelte | material/svelte | Svelte 5, SvelteKit |
| Solid | material/solid | Solid, SolidStart |
| Vanilla factories | material | The smallest bundles and full control |
Every app imports the base stylesheet once: the theme, the tokens a component reads, and the ripple. Type classes and the type scale are material/styles/typography (see Styles).
import 'material/styles/base';
Web components: register them once, then write HTML.
<script type="module">
import 'material/styles/base';
import 'material/elements/css';
import { defineAll } from 'material/elements';
defineAll();
</script>
<form>
<m-text-field name="email" type="email" label="Email" required></m-text-field>
<m-switch name="news" checked>Newsletter</m-switch>
<m-button type="submit">Sign up</m-button>
</form>
The script imports bare specifiers and stylesheets, so the page goes through a bundler such as Vite. Opened straight from disk, the browser cannot resolve them and the form stays unstyled.
React (Vue, Svelte and Solid work the same way, see below):
import { createRoot } from 'react-dom/client';
import 'material/styles/base';
import { Button, Switch, TextField } from 'material/react';
export function Signup() {
return (
<form>
<TextField name="email" type="email" label="Email" required />
<Switch name="news" defaultChecked>Newsletter</Switch>
<Button type="submit">Sign up</Button>
</form>
);
}
createRoot(document.getElementById('root')!).render(<Signup />);
React and React DOM are yours to install, and the page has a <div id="root">. In an app that already renders, leave out the first import and the last line, and use <Signup /> where you need it.
Vanilla: each component is a function that returns a DOM element and a small API.
import 'material/styles';
import { createButton, createTextField } from 'material';
const name = createTextField({ label: 'Name' });
const save = createButton({ text: 'Save', variant: 'filled' });
save.disabled.disable();
name.on('input', ({ value }: { value: string }) => {
if (value.trim()) save.disabled.enable();
else save.disabled.disable();
});
save.on('click', () => console.log('Saved', name.getValue()));
document.body.append(name.element, save.element);
When the view goes away, release the listeners and the DOM:
name.destroy();
save.destroy();
For hundreds of components created at once, such as a long editable table, use the factories: the elements style a shadow root each, which costs more on the first render. The Web Components guide has the measurement.
material/styles loads every component's styles; for a smaller bundle, import only what you use (see Styles).
Events, methods and cleanup are in the Vanilla guide.
Every component comes three ways:
createButton;<m-button>;Button (MButton in Vue).| Group | Components |
|---|---|
| Actions | Button, Icon button, Button group, Split button, |
fab-menu: a server-rendered FAB menu picks the wrong presentation in narrow windows
https://github.com/floor/material/issues/957
Labels: None
menu: an RTL menu that clamps left and caps its height moves on upgrade in Chromium
https://github.com/floor/material/issues/956
Labels: None
carousel: a server-rendered fluid carousel shifts on upgrade
https://github.com/floor/material/issues/955
Labels: None
carousel: keep server-only render code out of the client bundle
https://github.com/floor/material/issues/953
Labels: None
List-detail scaffold changes height on upgrade from hand-written markup
https://github.com/floor/material/issues/950
Labels: bug
App bars change size on upgrade from hand-written markup
https://github.com/floor/material/issues/949
Labels: bug
Slider moves on upgrade in RTL when server-rendered
https://github.com/floor/material/issues/947
Labels: bug
Text field and select move on upgrade in RTL when server-rendered
https://github.com/floor/material/issues/946
Labels: bug
Thank you for your interest in contributing to material! This document provides guidelines and instructions for contributing to this lightweight, TypeScript-focused UI component library.
Claude Code 2.1.277 or later reads AGENTS.md automatically in most setups (see the linked docs for exceptions), and so do Codex and Cursor. Contributor agents should start there for the checks and the rules, and use this guide for the whole workflow.
material aims to be a modern, flexible UI component library with:
By contributing to material, you'll help create a lean alternative to heavier frameworks while gaining experience with modern TypeScript patterns and component design.
Fork and clone the repository:
git clone https://github.com/YOUR-USERNAME/material.git
cd material
Install dependencies with Bun 1.4.5, the version CI runs:
bun install --frozen-lockfile
Install the Playwright browsers the browser checks drive:
bunx playwright install chromium webkit
material's documentation site, md3.io, is a separate repository (floor/md3.io) with a playground for every component. To see your changes there, clone it beside your material checkout; it depends on file:../material:
# Next to the material repository
git clone https://github.com/floor/md3.io.git
cd md3.io
bun install
# Serves http://localhost:4300 and rebuilds material, then the site, when material/src changes
bun run dev
Pick an issue or feature - Start with issues labeled good-first-issue or help-wanted.
Create a branch - Name your branch based on what you're working on:
git checkout -b feature/button-improvements
# or
git checkout -b fix/text-field-validation
Make your changes - Follow the coding standards and guidelines below.
Test your changes - Tests go in the same commit as the code (see Testing), and md3.io shows the component live (see above).
Submit a pull request - Include a detailed description of your changes and reference any related issues.
Each issue uses one template in .github/ISSUE_TEMPLATE/, and blank issues are off:
bug.md) — broken behaviour: a crash, wrong behaviour against the
documentation, a regression, a layout shift, RTL, an accessibility break. A measured difference
from m3.material.io or Compose Material 3 is filed as a bug too; the section below is about it.feature.md) — a missing component, variant or option; link the reference
when Material 3 specifies it, and it is tracked as a gap against the references.Both carry the same sections: Problem, Done when, Check, Scope and Gates. The Check names the command that proves the work, and it is required.
The library follows Material 3. Where a component looks or measures unlike the specification, the difference is a conformance drift.
bun run conformance <component> returns one JSON row per case — the measured
parts, their state, density, zoom and colour scheme — in Chromium, and with --webkit in
WebKit. bun run conformance --list names the fixtures; scripts/conformance/README.md covers
the cases and the Compose token extractor.08ec699d, see the token extractor in that README) and the page on
m3.material.io with the date you read it. The property tables are not
public, so the measurement and the sources are the reference.conformance/README.md; where a component page
on md3.io lists its Known issues, that section says the same for
that component.bug.md, with the measurement and
its command in the Check field. A maintainer labels a drift on triage with the conformance/*
family (drift-spec, drift-compose, drift-both, reference-conflict, deviation,
api-gap) and the component/* and aspect/* labels that fit, and the row stays in the
matrix until it is fixed.A component is a factory composed from small features with pipe: each with* function adds one capability to the component object and returns it.
// src/components/divider/divider.ts
import { createBase, withElement, pipe, withVariant } from "../../core/compose";
import { DividerConfig, createBaseConfig } from "./config";
import { withOrientation, withInset, withStyle } from "./features";
import { DividerComponent } from "./types";
export const createDivider = (config: DividerConfig = {}): DividerComponent => {
const processedConfig = createBaseConfig(config);
return pipe(
createBase,
withElement({ tag: "hr", componentName: "divider", className: config.class }),
withOrientation(processedConfig),
withVariant(processedConfig),
withInset(processedConfig),
withStyle(processedConfig)
)(processedConfig) as DividerComponent;
};
Read an existing component of the same kind before starting (src/components/divider is the