# 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`
`
}
#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
```
### 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` (`