# Material ESM (appoxy/material) > Pure ESM, zero-build Material Design 3 and M3 Expressive web components built on Lit 3. Import individual components directly from `material/...` via browser ` ``` ### Option 2: NPM ```sh npm install appoxy/material ``` Package name in `node_modules` is `material`, so bare specifiers (`import 'material/buttons/button.js'`) work directly with Vite, Rollup, esbuild, or import maps. ### Theme Tokens & Typography Components consume standard Material 3 CSS custom properties (`--md-sys-color-*`, `--md-ref-typeface-*`, `--md-sys-typescale-*`), falling back to M3 baseline defaults if unset. Export `light.css` and `dark.css` from [Material Theme Builder](https://material-foundation.github.io/material-theme-builder/): ```css @import url(light.css); @import url(dark.css) (prefers-color-scheme: dark); :root { --md-ref-typeface-brand: 'Google Sans Flex', sans-serif; --md-ref-typeface-plain: 'Google Sans Flex', sans-serif; font-family: var(--md-ref-typeface-plain); background: var(--md-sys-color-background); color: var(--md-sys-color-on-background); } ``` Optional typography utility classes (`.md-typescale-display-large`, `.md-typescale-headline-medium`, `.md-typescale-title-large`, `.md-typescale-body-medium`, `.md-typescale-label-large`, plus `-prominent` variants): ```js // Inside LitElement static styles: import { styles as typescaleStyles } from 'material/typography/md-typescale.js' // Or inject globally into document.head in non-Lit apps: import { injectTypescaleStyles } from 'material/typography/md-typescale.js' injectTypescaleStyles() ``` ### Using in Lit Components ```js import { LitElement, html, css } from 'lit' import 'material/text/text-field.js' import 'material/buttons/button.js' import { snack } from 'material/snackbar/snackbar.js' class ProfileForm extends LitElement { static properties = { name: { type: String } } static styles = css` form { display: flex; flex-direction: column; gap: 16px; max-width: 360px; } ` constructor() { super() this.name = '' } render() { return html`
(this.name = e.target.value)}> Save
` } #onSubmit(e) { e.preventDefault() snack(`Saved ${this.name}`) } } customElements.define('profile-form', ProfileForm) ``` --- ## Component Reference ### 1. App Bar (``) - **Import**: `import 'material/app/bar.js'` - **Attributes / Props**: - `type` (alias `variant`): `'small'` (default) | `'center-aligned'` | `'medium-flexible'` | `'large-flexible'` | `'search'` - `headline` (alias `title`): `string` — primary title text - `subtitle`: `string` — optional subtitle - `center-aligned` (`centerAligned`): `boolean` - `scroll-behavior` (`scrollBehavior`): `'none'` (default) | `'scroll'` (elevates on scroll) | `'collapse'` (collapses medium/large flexible bars to 64px) - `scroll-target` (`scrollTarget`): `'window'` (default) or CSS selector of scroll container - `scrolled`, `collapsed`: `boolean` (reflected state) - `placeholder`, `value`: `string` (used when `type="search"`) - **Slots**: `navigation-icon` (alias `leading-icon`), `headline` (alias `title`), `subtitle`, `action-items` (alias `trailing-icon`), `search-field`, `suggestions`, `(default)` (under-bar content like ``). ```html menu
search
``` ### 2. Badge (``) - **Import**: `import 'material/badge/badge.js'` - **Attributes / Props**: - `value`: `string` (`''` default renders a `6px` dot badge; non-empty string renders a `16px` pill count badge, e.g. `"5"` or `"99+"`) - `inline`: `boolean` (`false` default is `position: absolute` anchored to icon; `true` flows inline in flex/text) - **Built-in `slot="badge"` hosts**: ``, ``, and `` position `` automatically. ```html notifications ``` ### 3. Buttons (``, ``, ``, ``, ``) #### `` - **Import**: `import 'material/buttons/button.js'` - **Attributes / Props**: - `color`: `'filled'` (default) | `'outlined'` | `'elevated'` | `'tonal'` | `'text'` - `size`: `'small'` (default) | `'extra-small'` | `'medium'` | `'large'` | `'extra-large'` - `shape`: `'round'` (default) | `'square'` - `disabled`, `toggle`, `selected`, `checkmark`, `trailing-icon` (`trailingIcon`): `boolean` - `href`, `target`: `string` (renders as link) - `type`: `'submit'` (default) | `'button'` | `'reset'`; `name`, `value`: `string` (form-associated; also supports `form="..."` in dialogs) - **Slots**: `(default)` label text, `icon` (leading/trailing ``). ```html addCreate Cancel ``` #### `` - **Import**: `import 'material/buttons/button-group.js'` - **Attributes / Props**: - `connected`: `boolean` — Material 3 Expressive connected toggle group (replaces legacy segmented button) - `multiselect`: `boolean` (`false` default = single-select when `connected`) - `selection-required` (`selectionRequired`): `boolean` (`true` default) - `checkmark`: `boolean` — shows checkmark on selected button(s) - `size`: `'extra-small'` | `'small'` | `'medium'` | `'large'` | `'extra-large'` - **Events**: `change` (`detail: { button, selected, value, selectedIndex }`). ```html Day Week Month ``` #### `` - **Import**: `import 'material/buttons/icon-button.js'` - **Attributes / Props**: - `color`: `'standard'` (default) | `'filled'` | `'tonal'` | `'outlined'` - `size`: `'small'` (default) | `'extra-small'` | `'medium'` | `'large'` | `'extra-large'` - `toggle`, `selected`, `disabled`, `flip-icon-in-rtl`: `boolean` - `aria-label-selected`, `href`, `target`, `type`, `name`, `value`: `string` - **Slots**: `(default)` ``, `selected` (alternate `` when `toggle` + `selected`), `badge` (``). - **Events**: `input`, `change` (when `toggle` is set). #### `` - **Import**: `import 'material/buttons/fab.js'` - **Attributes / Props**: - `variant`: `'surface'` (default) | `'primary'` | `'secondary'` | `'tertiary'` - `size`: `'small'` (default) | `'medium'` | `'large'` - `label`: `string` — text label; pair with `extended` (`boolean`) for Extended FAB - `lowered`: `boolean`; `href`, `target`: `string` - **Slots**: `icon` (`add`). #### `` - **Import**: `import 'material/buttons/split-button.js'` - **Attributes / Props**: `color` (`'filled'` default | `'tonal'` | `'outlined'` | `'elevated'`), `size` (`'small'` default), `disabled` (`boolean`), `separator-type`. - **Slots**: `(default)` primary button label/content, `menu` (`` list inside a wrapper or menu). ```html Send
Schedule send
Save draft
``` ### 4. Card (``) - **Import**: `import 'material/card/card.js'` - **Attributes / Props**: `type`: `'outlined'` (default) | `'elevated'` | `'filled'` - **Slots**: `(default)` card content (apply your own padding/layout inside or on ``). ```html Card content ``` ### 5. Carousel (``, ``) - **Import**: - `import 'material/carousel/carousel.js'` - `import 'material/carousel/carousel-item.js'` - **`` Props**: - `layout`: `'multi-browse'` (default) | `'uncontained'` | `'hero'` | `'centered-hero'` | `'full-screen'` - `item-width` (`itemWidth`): `string` (e.g. `'320px'`); `item-spacing` (`itemSpacing`): `number` (`8` default) - `navigation`: `'auto'` (default) | `'always'` | `'none'` - `indicators`, `loop`: `boolean`; `autoplay`: `number` (ms, `0` = off); `active-index` (`activeIndex`): `number` - `scroll-snap` (`true` default), `hide-scrollbar` (`true` default): `boolean` - **`` Methods & Events**: `next()`, `previous()`, `scrollToIndex(index, behavior)`; fires `change` (`detail: { index, item }`), `scroll`. - **`` Props & Slots**: `headline`, `subhead`, `shape`, `type` (`'filled' | 'elevated' | 'outlined'`), `interactive` (`boolean`), `href`, `target`. Slots: `(default)`, `headline`, `subhead`, `scrim`, `action`. ### 6. Checkbox (``) - **Import**: `import 'material/checkbox/checkbox.js'` - **Attributes / Props**: `checked`, `indeterminate`, `disabled`, `required`: `boolean`; `name`, `value`: `string` (`'on'` default). Form-associated. - **Events**: `change`, `input` (read `e.target.checked`). ### 7. Chips (``, ``) - **Import**: - `import 'material/chips/chip-set.js'` - `import 'material/chips/chip.js'` - **`` Props**: - `type`: `'assist'` (default) | `'filter'` | `'input'` | `'suggestion'` - `label`: `string`; `value`: `string` - `selected`, `elevated`, `removable`, `disabled`, `avatar`, `always-focusable`, `remove-only`: `boolean` - `href`, `target`: `string` - **`` Slots**: `icon` (``), `selected-icon` (for `type="filter"`). ```html ``` ### 8. Dialog (``) - **Import**: `import 'material/dialog/dialog.js'` - **Attributes / Props**: - `open`: `boolean`; `return-value` (`returnValue`): `string` - `type`: `''` (default) | `'alert'` (`role="alertdialog"`, disables scrim-click dismissal) - `prevent-scrim-close` (`preventScrimClose`), `stacked`, `fullscreen`, `quick`: `boolean` - **Methods**: `await dialog.show()`, `await dialog.close(returnValue?)` - **Slots**: `icon` (optional header ``), `headline`, `content` (`
` or `
`), `actions` (`` controls). - **Events**: `open`, `opened`, `close`, `closed`, `cancel`. ```html
Delete project?
This action cannot be undone.
Cancel Delete
``` ### 9. Divider (``) - **Import**: `import 'material/divider/divider.js'` - **Attributes / Props**: `inset`, `inset-start` (`insetStart`), `inset-end` (`insetEnd`): `boolean`. ### 10. Icon (``) - **Import**: `import 'material/icon/icon.js'` - **Usage**: `settings` (Material Symbols ligature) or `...`. ### 11. Indicators (``, ``) #### `` - **Import**: `import 'material/indicators/progress.js'` - **Attributes / Props**: - `type`: `'circular'` (default) | `'linear'` - `shape`: `'flat'` (default) | `'wavy'` (M3 Expressive sinusoidal wave) - `value`: `number` (`0` to `max`); `max`: `number` (`1` default); `buffer`: `number` (linear buffer) - `indeterminate`, `four-color` (`fourColor`): `boolean` ```html ``` #### `` - **Import**: `import 'material/indicators/loading.js'` - **Description**: M3 Expressive spring-physics morphing 7-shape loader. - **Attributes / Props**: `contained` (`boolean`), `size` (`number`, `48` default), `color` (`string`), `container-color` (`string`), `speed` (`number`, `1` default), `paused` (`boolean`). ### 12. List (``, ``) - **Import**: - `import 'material/list/list.js'` - `import 'material/list/list-item.js'` - **`` Props**: `type`: `'text'` (default) | `'button'` | `'link'`; `disabled`: `boolean`; `href`, `target`: `string`. - **`` Slots**: `headline`, `supporting-text`, `trailing-supporting-text`, `overline`, `start` (leading ``, avatar ``, checkbox), `end` (trailing ``, switch, metadata). ### 13. Menu (``, ``, ``) - **Import**: - `import 'material/menu/menu.js'` - `import 'material/menu/menu-item.js'` - `import 'material/menu/sub-menu.js'` (optional, for nested menus; add `has-overflow` on parent ``) - **`` Props**: - `anchor`: `string` — `id` of anchor element in the same root node (wrap anchor + menu in `position: relative` container, or set `positioning="popover"` / `"fixed"`) - `open`, `quick`, `has-overflow` (`hasOverflow`): `boolean` - `variant`: `'vertical'` (default M3 Expressive) | `'baseline'`; `color-style` (`colorStyle`): `'standard'` (default) | `'vibrant'` - `positioning`: `'absolute'` (default) | `'fixed'` | `'document'` | `'popover'` - `anchor-corner` (`'end-start'`), `menu-corner` (`'start-start'`), `x-offset`, `y-offset` - **`` Methods**: `show()`, `close()` - **`` Props & Slots**: `selected`, `disabled`, `keep-open` (`keepOpen`): `boolean`; `href`, `target`, `type`. Slots: `headline`, `supporting-text`, `trailing-supporting-text`, `start`, `end`. ```html
Actions edit
Edit
delete
Delete
``` ### 14. Navigation (``, ``, ``) - **Import**: - `import 'material/nav/rail.js'` — vertical desktop/tablet rail (96px compact, 220–360px `expanded`, or modal drawer) - `import 'material/nav/bar.js'` — horizontal bottom navigation bar for mobile (3–5 destinations) - `import 'material/nav/item.js'` — destination item used inside `` or `` - **`` Props, Methods, Slots & Events**: - Props: `active-index` (`activeIndex`, `number`), `expanded` (`boolean`), `hide-inactive-labels` (`boolean`) - Method: `toggleExpanded()` - Slots: `menu` (overrides built-in expand menu button), `fab` (``), `(default)` (`` children) - Events: `navigation-bar-activated` (`detail: { tab, activeIndex }`), `expanded-change` (`detail: { expanded }`) - **`` Props & Events**: `active-index`, `hide-inactive-labels`; fires `navigation-bar-activated`. - **`` Props & Slots**: `label` (`string`), `href` (`string`), `active`, `disabled`, `expanded`: `boolean`. Slots: `active-icon`, `inactive-icon`, `badge` (``). ```html home home notifications notifications ``` ### 15. Pickers (``, ``, ``) - **Import**: - `import 'material/pickers/date-picker.js'` — inline calendar (`value="YYYY-MM-DD"`, `min`, `max`, `hide-header`; fires `change`, `input`) - `import 'material/pickers/time-picker.js'` — inline clock dial (`value="HH:MM"`, `format="12"` or `"24"`; fires `change`, `input`) - `import 'material/pickers/datetime-picker-dialog.js'` — modal dialog (`type="date" | "time" | "datetime-local"`, `value`, `min`, `max`, `format`; methods `show()`, `close()`; fires `confirm`, `cancel`, `change`, `close`) - **Tip**: `` automatically embeds `` with a trigger button. ### 16. Radio (``) - **Import**: `import 'material/radio/radio.js'` - **Attributes / Props**: `name`, `value`: `string`; `checked`, `disabled`, `required`: `boolean`. Form-associated. Fires `change`, `input`. ### 17. Search (``) - **Import**: `import 'material/search/search.js'` - **Attributes / Props**: - `value`, `placeholder` (`'Search'`), `label` (`'Search'`), `name`: `string` - `view`: `'auto'` (default: docked `>= 600px`, fullscreen `< 600px`) | `'docked'` | `'fullscreen'` - `open`, `elevated`, `center-aligned`, `disabled`, `no-clear`, `no-filter`: `boolean` - **Slots**: `(default)` or `suggestions` (`` / `` auto-filtered unless `no-filter`), `leading-icon`, `trailing-icon`, `avatar`. - **Events**: `input`, `change`, `search` (`detail: { value }` on Enter), `clear`, `open`, `close`. ### 18. Select (``, ``) - **Import**: - `import 'material/select/select.js'` - `import 'material/select/select-option.js'` - **`` Props**: - `color`: `'outlined'` (default) | `'filled'` - `label`, `value`, `supportingtext` (`supportingText`), `errortext` (`errorText`), `display-text` (`displayText`): `string` - `selected-index` (`selectedIndex`): `number`; `required`, `disabled`, `error`, `clamp-menu-width`, `quick`: `boolean` - `menu-positioning` (`menuPositioning`): `'popover'` (default) | `'fixed'` | `'absolute'` - **`` Props & Slots**: `value`: `string`; `selected`, `disabled`: `boolean`; `display-text`, `typeahead-text`: `string`. Slots: `headline`, `supporting-text`, `start`, `end`. - **Events**: `change`, `input`, `opening`, `opened`, `closing`, `closed` (read `e.target.value`). ```html
Viewer
Editor
Admin
``` ### 19. Sheet (``) - **Import**: `import 'material/sheet/sheet.js'` - **Description**: Unified M3 Bottom Sheet and Side Sheet (modal or coplanar standard). - **Attributes / Props**: - `position`: `'bottom'` (default) | `'end'` (or `'side'`) | `'start'` | `'right'` | `'left'` - `open`: `boolean`; `modal`: `boolean` (`true` default; set `modal="false"` + optional `inline` for coplanar standard side sheets) - `headline`: `string`; `divider`, `detached`, `full-width`, `has-back-button`, `has-drag-handle`, `has-close-button`, `prevent-scrim-close`, `quick`: `boolean` - **Methods**: `await sheet.show()`, `await sheet.close(returnValue?)` - **Slots**: `(default)` scrollable body, `headline`, `actions`, `drag-handle`, `back-button`, `close-button`. - **Events**: `open`, `opened`, `close`, `closed`, `cancel`, `back`. ```html

Filter options...

Apply
``` ### 20. Slider (``) - **Import**: `import 'material/slider/slider.js'` - **Attributes / Props**: - `min` (`0`), `max` (`100`), `step` (`1`), `value` (`50`): `number` - `range`: `boolean` — dual-thumb range mode using `value-start` (`valueStart`) and `value-end` (`valueEnd`) - `labeled`, `ticks`, `disabled`: `boolean`; `value-label`, `value-label-start`, `value-label-end`: `string` - **Events**: `input`, `change` (read `e.target.value` or `e.target.valueStart` / `e.target.valueEnd`). ### 21. Snackbar (`` & `snack()`) - **Import**: `import { snack } from 'material/snackbar/snackbar.js'` (also registers ``) - **`snack(message, options?)` Helper** (recommended): - Auto-dismisses after 5s when non-actionable; stays open until dismissed when `action` or `showCloseIcon` is set. - `options`: `{ duration?: number, stacked?: boolean, showCloseIcon?: boolean, action?: { label: string, onClick: () => void } }` - **Declarative ``**: Props `message`, `open`, `stacked`, `duration`, `show-close-icon`; slot `action`; methods `show()`, `close()`. ```js import { snack } from 'material/snackbar/snackbar.js' snack('Item archived', { action: { label: 'Undo', onClick: () => restoreItem() }, showCloseIcon: true, }) ``` ### 22. Switch (``) - **Import**: `import 'material/switch/switch.js'` - **Attributes / Props**: `selected` (`boolean` — **note**: uses `selected`, not `checked`), `icons` (`boolean`), `show-only-selected-icon` (`boolean`), `disabled`, `required`: `boolean`; `name`, `value`: `string`. - **Events**: `change`, `input` (read `e.target.selected`). ### 23. Tabs (``, ``) - **Import**: - `import 'material/tabs/tabs.js'` - `import 'material/tabs/tab.js'` - **`` Props & Events**: `active-tab-index` (`activeTabIndex`, `number`), `auto-activate` (`boolean`), `scrollable` (`boolean`); fires `change` (`e.target.activeTabIndex`). - **`` Props & Slots**: `type`: `'primary'` (default) | `'secondary'`; `inline-icon` (`inlineIcon`, `boolean`), `active`, `disabled`: `boolean`. Slots: `(default)` label text, `icon` (``), `badge` (``). ```html photoPhotos videocamVideos ``` ### 24. Text Field (``) - **Import**: `import 'material/text/text-field.js'` - **Attributes / Props**: - `color`: `'outlined'` (default) | `'filled'` - `type`: `'text'` (default) | `'textarea'` | `'email'` | `'password'` | `'number'` | `'search'` | `'tel'` | `'url'` | `'color'` | `'date'` | `'time'` | `'datetime-local'` - `label`, `value`, `placeholder`, `supporting-text` (`supportingText`), `error-text` (`errorText`), `prefix-text` (`prefixText`), `suffix-text` (`suffixText`): `string` - `required`, `disabled`, `readonly` (`readOnly`), `error`, `no-spinner`: `boolean` - `rows`, `cols`, `minlength` (`minLength`), `maxlength` (`maxLength`): `number`; `min`, `max`, `step`, `pattern`, `autocomplete`, `inputmode` (`inputMode`): `string` - Methods: `checkValidity()`, `reportValidity()`, `setCustomValidity(msg)`, `focus()`, `select()`, `reset()` - **Slots**: `leading-icon` (``), `trailing-icon` (`` or ``). - **Events**: `input`, `change`, `select` (read `e.target.value`). ```html payments ``` ### 25. Tooltip (``) - **Import**: `import 'material/tooltip/tooltip.js'` - **Usage**: Wrap the target trigger element inside ``. - **Attributes / Props**: `type`: `'plain'` (default) | `'rich'`; `text`: `string`; `headline`: `string` (rich); `open`: `boolean`. - **Slots**: `(default)` trigger element, `headline` (rich), `text`, `actions` (rich). ```html content_copy ``` --- ## Documentation - [Repository Overview](https://raw.githubusercontent.com/appoxy/material/main/README.md): Quick start, CDN importmap, fonts, and theming setup. - [Live Interactive Demo](https://appoxy.github.io/material/demo/): Material 3 Expressive component showcase. - [App Bar](https://raw.githubusercontent.com/appoxy/material/main/app/README.md): Small, center-aligned, medium/large flexible, and search top app bars. - [Badge](https://raw.githubusercontent.com/appoxy/material/main/badge/README.md): Small dot and large count notification badges. - [Buttons](https://raw.githubusercontent.com/appoxy/material/main/buttons/README.md): Expressive buttons, connected button groups, icon buttons, FABs, and split buttons. - [Card](https://raw.githubusercontent.com/appoxy/material/main/card/README.md): Outlined, elevated, and filled cards. - [Carousel](https://raw.githubusercontent.com/appoxy/material/main/carousel/README.md): Multi-browse, uncontained, hero, centered-hero, and full-screen carousels. - [Checkbox](https://raw.githubusercontent.com/appoxy/material/main/checkbox/README.md): Form-associated checkboxes with indeterminate state. - [Chips](https://raw.githubusercontent.com/appoxy/material/main/chips/README.md): Assist, filter, input, and suggestion chips and chip sets. - [Dialog](https://raw.githubusercontent.com/appoxy/material/main/dialog/README.md): Modal, alert, stacked-action, and fullscreen dialogs. - [Divider](https://raw.githubusercontent.com/appoxy/material/main/divider/README.md): Full-bleed and inset dividers. - [Icon](https://raw.githubusercontent.com/appoxy/material/main/icon/README.md): Material Symbols ligature and custom SVG icons. - [Indicators](https://raw.githubusercontent.com/appoxy/material/main/indicators/README.md): Circular/linear progress (flat & wavy) and morphing loading indicators. - [List](https://raw.githubusercontent.com/appoxy/material/main/list/README.md): Single-line, multi-line, interactive button, and link lists. - [Menu](https://raw.githubusercontent.com/appoxy/material/main/menu/README.md): Expressive vertical menus, vibrant menus, baseline menus, and nested submenus. - [Navigation](https://raw.githubusercontent.com/appoxy/material/main/nav/README.md): Navigation rail, modal navigation drawer pattern, bottom navigation bar, and nav items. - [Pickers](https://raw.githubusercontent.com/appoxy/material/main/pickers/README.md): Inline date/time pickers and modal date/time/datetime picker dialogs. - [Radio](https://raw.githubusercontent.com/appoxy/material/main/radio/README.md): Form-associated radio buttons. - [Search](https://raw.githubusercontent.com/appoxy/material/main/search/README.md): Search bar with adaptive docked and full-screen suggestion views. - [Select](https://raw.githubusercontent.com/appoxy/material/main/select/README.md): Outlined and filled select dropdown menus. - [Sheet](https://raw.githubusercontent.com/appoxy/material/main/sheet/README.md): Modal and standard bottom sheets and side sheets. - [Slider](https://raw.githubusercontent.com/appoxy/material/main/slider/README.md): Continuous, discrete tick, labeled, and dual-thumb range sliders. - [Snackbar](https://raw.githubusercontent.com/appoxy/material/main/snackbar/README.md): Declarative snackbars and imperative `snack()` helper. - [Switch](https://raw.githubusercontent.com/appoxy/material/main/switch/README.md): Form-associated toggle switches with optional icons. - [Tabs](https://raw.githubusercontent.com/appoxy/material/main/tabs/README.md): Primary, secondary, inline-icon, and scrollable tabs. - [Text Field](https://raw.githubusercontent.com/appoxy/material/main/text/README.md): Outlined/filled text fields, textareas, color inputs, and integrated date/time pickers. - [Tooltip](https://raw.githubusercontent.com/appoxy/material/main/tooltip/README.md): Plain and rich interactive tooltips.