npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@md-expressive/web-components

v0.0.4

Published

Material 3 Expressive web components built with Stencil, modelled on Jetpack Compose Material 3 and AOSP.

Readme

md-expressive

Material 3 Expressive web components, built with Stencil, using Jetpack Compose Material 3 and AOSP as the reference. Components: <md-app-bar>, <md-badge>, <md-button>, <md-button-group>, <md-split-button>, <md-fab>, <md-fab-menu>, <md-icon-button>, <md-switch>, <md-checkbox>, <md-slider>, <md-range-slider>, <md-ripple>, <md-dialog>, <md-snackbar>, <md-snackbar-host>, <md-tabs>, <md-tab>, <md-toolbar>, <md-floating-toolbar>, <md-tooltip>, <md-rich-tooltip>, <md-icon>, <md-scroll-field>, <md-time-picker>, <md-time-picker-dialog>.

Install

npm install @md-expressive/web-components

Register the elements once, in one of three ways:

// Every component, each loaded on first use (the smallest start-up cost).
import { defineCustomElements } from '@md-expressive/web-components/loader';
defineCustomElements();

// Or only the ones you use, bundled with your code.
import { defineCustomElement as defineButton } from '@md-expressive/web-components/components/md-button.js';
defineButton();
<!-- Or without a bundler, from a CDN. -->
<script type="module" src="https://cdn.jsdelivr.net/npm/@md-expressive/web-components/dist/md-expressive/md-expressive.esm.js"></script>

Add the type scale stylesheet (dist/md-expressive/md-expressive.css) and the Roboto Flex font (see Fonts & icons). Utilities such as applyTheme and configureFonts are exported from @md-expressive/web-components.

React: @md-expressive/react wraps every element as a React component (<Button>, <Switch onMdChange={…}>), for React 18 and 19.

Changes and events

When someone changes a control, its md* event fires before the change is applied, with the new value in detail, and it's cancelable, like Compose's onCheckedChange(newValue):

  • mdChange on switches, checkboxes, radios, toggle buttons, filter chips, list and menu items, tabs, navigation bars and rails, and the date pickers; mdInput on sliders, range sliders, scroll fields, text fields and the time picker (their mdChange reports a finished interaction).
  • Call preventDefault() to refuse it: the control keeps its value (a switch's thumb springs back, a refused keystroke never appears). To replace it, refuse it and set the value you want:
slider.addEventListener('mdInput', (e) => {
  if (e.detail.value > 50) { e.preventDefault(); slider.value = 50; }
});
field.addEventListener('mdInput', (e) => {
  e.preventDefault();
  field.value = e.detail.value.toUpperCase(); // the caret stays where it was
});
  • Read the new value from e.detail: during the event the element still has the old one.
  • The native input and change events fire afterwards, once the value has changed, so code that listens for them (and forms) sees the applied value.
  • Setting a property from script (el.checked = true) and form resets fire nothing.

Developing

bun install
bun start        # dev server with the demo page (src/index.html)
bun run build    # dist/, loader/, hydrate/, the demo in www/, and react/src/components.ts
cd react && bun run build   # the React package (react/dist/)

Usage

<md-theme source="#6750A4">          <!-- optional: generates --md-sys-color-* from a seed -->
  <md-button>Filled</md-button>
  <md-button variant="tonal" size="m" shape="square">
    <svg slot="icon" …/> Save
  </md-button>
  <md-button toggle variant="outlined">Bookmark</md-button>
</md-theme>

| Prop | Values | Default | |---|---|---| | variant | elevated filled tonal outlined text | filled | | size | xs s m l xl | s | | shape | round square | round | | toggle / selected | boolean | false | | disabled | boolean | false | | pressed | holds the pressed shape and state layer (an open <md-menu> sets it on its anchor) | false | | expanded | for a button that shows and hides something: sets aria-expanded (leave unset otherwise) | – | | href target rel download | renders an <a> | – | | type | button submit reset (form-associated) | button |

Event: mdChange { selected } on toggle buttons. Slots: default, icon. CSS: --md-button-container-color, --md-button-label-color, ::part(button). Programmatic theming: applyTheme('#6750A4', element, 'auto').

Button groups

<md-button-group aria-label="Message actions">
  <md-button variant="tonal">Reply</md-button>
  <md-button variant="tonal">Forward</md-button>
</md-button-group>

<md-button-group connected selection="single" aria-label="Calendar view">
  <md-button toggle variant="tonal" selected>Day</md-button>
  <md-button toggle variant="tonal">Week</md-button>
</md-button-group>

Groups md-buttons and md-icon-buttons. A pressed button widens by 15% and nudges its neighbours aside (each gives up at most 16px). connected: 2px apart, round outer corners and small inner corners, fully round when selected. selection: single (exactly one selected, like radio buttons), multiple, or none (default; you manage selected). Children with data-weight share the width. CSS: --md-button-group-gap (12px / 2px). The group sets group-position and connected on its buttons.

Split button

<md-split-button menu-label="More send options">
  <md-icon slot="icon">send</md-icon> Send
</md-split-button>

| Prop | Notes | Default | |---|---|---| | variant | filled tonal elevated outlined | filled | | size | xs s m l xl | s | | expanded | the menu is open; toggled by the arrow | false | | menu-label | accessible name of the arrow button | More options | | disabled | | false |

The main part fires the host's click; the arrow toggles expanded and fires mdToggle { expanded } (open your menu there). Slots: default (label), icon, trailing-icon. Parts: leading, trailing.

FAB

<md-fab label="Compose"><md-icon slot="icon">edit</md-icon></md-fab>
<md-fab label="Compose" extended size="medium" color="secondary"><md-icon slot="icon">edit</md-icon></md-fab>

| Prop | Notes | Default | |---|---|---| | label | accessible name; the visible text when extended | – | | size | small (40) default (56) medium (80) large (96); extended: 56 / 80 / 96 | default | | color | primary-container secondary-container tertiary-container primary secondary tertiary | primary-container | | extended | shows the label; toggling it animates the FAB open or closed | false | | visible | false shrinks it into its corner and fades it out | true | | anchor | start or end: the corner it shrinks into when hidden | end | | lowered | elevation 1 instead of 3 | false | | disabled | | false |

Position it yourself (usually fixed to the bottom-end corner). Slot: icon. Parts: button, container. CSS: --md-fab-container-color, --md-fab-content-color.

FAB menu

<md-fab-menu label="Create" style="position: fixed; right: 0; bottom: 0">
  <md-fab-menu-item label="Note"><md-icon slot="icon">note_stack</md-icon></md-fab-menu-item>
  <md-fab-menu-item label="Checklist"><md-icon slot="icon">checklist</md-icon></md-fab-menu-item>
</md-fab-menu>

<md-fab-menu>: open, label (the toggle's accessible name), size (default medium large: the toggle's size when closed), align (end / start); event mdToggle { open }; slots: default (items, top to bottom), icon, close-icon. It includes its 16px margins. Choosing an item closes the menu (the item's click still reaches you), as does Escape; Tab or Down from the open toggle moves to the first item. <md-fab-menu-item>: label, disabled, slot icon, CSS --md-fab-menu-item-container-color, --md-fab-menu-item-content-color.

App bar

<md-app-bar variant="medium" scroll-behavior="exit-until-collapsed">
  <md-icon-button slot="leading" label="Back"><md-icon>arrow_back</md-icon></md-icon-button>
  Saved podcasts
  <span slot="subtitle">12 episodes</span>
  <md-icon-button slot="trailing" label="Search"><md-icon>search</md-icon></md-icon-button>
</md-app-bar>

| Prop | Notes | Default | |---|---|---| | variant | small (64px), medium or large (the M3 Expressive flexible bars: the title sits in a row of its own, wraps, and the bar grows to fit) | small | | centered | centres the title and subtitle | false | | scroll-behavior | none, pinned (turns surface container when content scrolls under it), enter-always (hides on scroll down, returns on scroll up; medium/large collapse to the small bar), exit-until-collapsed (medium/large shrink to the small bar as you scroll) | none | | scroll-target | id of the scrolling element; defaults to the nearest scrolling ancestor, else the page | – |

Put it first in the page or scroll container it belongs to: it's position: sticky, so it stays at the top. A bar left half-collapsed when scrolling stops snaps open or shut. Slots: default (title, or an image/logo), subtitle, leading (navigation button), trailing (actions, avatar, or one filled icon button). Parts: container, top-row, title-row. CSS: --md-app-bar-{container,scrolled-container,title,subtitle,leading-icon,trailing-icon}-color. The search app bar comes with the search component.

Navigation bar

<md-navigation-bar label="Main" value="home">
  <md-navigation-bar-item value="home"><md-icon slot="icon">home</md-icon>Home</md-navigation-bar-item>
  <md-navigation-bar-item value="explore"><md-icon slot="icon">explore</md-icon>Explore</md-navigation-bar-item>
  <md-navigation-bar-item value="inbox">
    <md-badged slot="icon"><md-icon>mail</md-icon><md-badge slot="badge" value="3"></md-badge></md-badged>
    Inbox
  </md-navigation-bar-item>
</md-navigation-bar>

The M3 Expressive flexible navigation bar: 64px, for 3–5 destinations along the bottom of compact and medium windows. (The older 80px bar is no longer recommended by M3 and isn't included.)

| <md-navigation-bar> prop | Notes | Default | |---|---|---| | value | the selected item's value | – | | arrangement | equal-weight (every item the same width; compact windows) or centered (items grouped in the middle, growing to fit their labels; medium windows) | equal-weight | | icon-position | top (icon above the label) or start (icon before the label, in a 40px indicator; medium windows); applied to every item | top | | label | accessible name of the navigation landmark | – |

Pressing an item selects it, sets value and fires change and mdChange ({value, item}). To route yourself, call preventDefault() on the item's click and set value when you're done. The bar pads itself for the bottom and side safe areas (needs viewport-fit=cover). CSS: --md-navigation-bar-container-color.

| <md-navigation-bar-item> prop | Notes | Default | |---|---|---| | value | identifies the item | – | | selected | managed by the bar | false | | disabled | | false | | href, target | make the item a link | – | | label | accessible name for an item without a visible label | – |

Slots: default (label), icon (wrap it in <md-badged> for a badge; an md-icon fills in while selected). The selected item has aria-current="page". Parts: item, indicator. CSS: --md-navigation-bar-{indicator,icon,selected-icon,label,selected-label}-color.

Navigation rail

<div style="display: flex; height: 100vh">
  <md-navigation-rail label="Mail" value="inbox">
    <md-icon-button slot="header" label="Expand navigation" style="margin-inline-start: 24px"
      onclick="this.closest('md-navigation-rail').toggle()"><md-menu-icon></md-menu-icon></md-icon-button>
    <md-fab slot="header" label="Compose" lowered style="margin: 4px 0 0 20px"><md-icon slot="icon">edit</md-icon></md-fab>
    <md-navigation-rail-item value="inbox"><md-icon slot="icon">inbox</md-icon>Inbox</md-navigation-rail-item>
    <md-navigation-rail-item value="sent"><md-icon slot="icon">send</md-icon>Sent</md-navigation-rail-item>
  </md-navigation-rail>
  <main>…</main>
</div>

The M3 Expressive navigation rail, which also replaces the navigation drawer (M3 no longer recommends the drawer or the baseline 80dp rail, so neither is included). Collapsed it's 96px with the icons above the labels; expanded it fits its items (220–360px) with the icons before the labels. Expanding and collapsing morph the width and every item on a spring.

| Prop | Notes | Default | |---|---|---| | value | the selected item's value | – | | expanded | wider, icons before labels; also expand(), collapse(), toggle() | false | | modal | expands over the page in a dialog with a scrim (Escape or a scrim click collapses it); the collapsed rail stays in place | false | | hide-on-collapse | with modal: hidden while collapsed; it slides in from the edge, can be swiped away, and closes when an item is picked | false | | label | accessible name of the navigation landmark | – |

Events: change and mdChange ({value, item}) when pressing an item changes the selection (preventDefault() on the item's click to route yourself), mdExpandedChange ({expanded}). Slots: default (items), header (a menu button and/or FAB; the items start 40px below it). Wire the menu button and the FAB's extended to mdExpandedChange yourself, as in the demo; <md-menu-icon> (set open while expanded) is a menu icon that animates into menu_open, its bars shortening as the chevron slides in (the library's own; Compose swaps icons). The rail fills its container's height and pads for the top, bottom and start safe areas. More items than fit scroll under the header (the library's addition). Other elements between the items, such as group headings, stay in place among them (the demo's rail uses them; they're best in a rail that's always expanded). Part: container. CSS: --md-navigation-rail-{container,modal-container,scrim}-color.

<md-navigation-rail-item> has the same props, slots and parts as <md-navigation-bar-item> (value, selected, disabled, href, target, label; icon slot), with --md-navigation-rail-{indicator,icon,selected-icon,label,selected-label}-color. Its press target spans the rail's full width.

Search

<md-search-app-bar scroll-behavior="enter-always">
  <md-icon-button slot="leading" label="Menu"><md-icon>menu</md-icon></md-icon-button>
  <md-search placeholder="Search mail">
    <md-list>
      <md-list-item type="button"><md-icon slot="leading">history</md-icon>Flight confirmation</md-list-item>
    </md-list>
  </md-search>
  <md-icon-button slot="trailing" label="Account"><md-icon>account_circle</md-icon></md-icon-button>
</md-search-app-bar>

<md-search placeholder="Search places">
  <md-icon-button slot="trailing" label="Voice search"><md-icon>mic</md-icon></md-icon-button>
  <img slot="trailing" src="me.jpg" alt="Account">
  <md-list>…</md-list>
</md-search>

The M3 Expressive search, contained style: a 56px pill (surface container high) that expands into a view of suggestions or results. Full-screen, the bar rises to the top of the window and widens to 8px from its edges over a surface container low view; docked, the results drop down 2px under the bar (12px corners, at least 240px and at most half the window tall) over a scrim. The divided (baseline) style isn't included; M3 no longer recommends it. There's a single input throughout, so focus, the caret and the IME carry over.

| Prop | Notes | Default | |---|---|---| | value | the query | '' | | placeholder | supporting text while the query is empty | 'Search' | | label | accessible name | the placeholder | | layout | full-screen, docked, or auto (docked from 600px wide) | 'auto' | | expanded | the view is open; also expand() (focuses the field) and collapse() | false | | disabled, name, autocomplete | as on <input> | – |

Clicking the bar, typing into it or pressing the down arrow expands it; the down arrow then moves into the results. The back button (which replaces the search icon while expanded), Escape and, when docked, a click on the scrim collapse it; picking a result is yours to handle (call collapse()). While expanded with a query, a clear button appears. Focus returns to the field when it collapses, except after touch, where it's dropped so the keyboard closes.

Events: native input and change; mdSearch ({value}) on Enter; mdExpandedChange ({expanded, layout}) as it starts opening or closing. Slots: default (results, shown while expanded; md-list-items get a transparent container), leading (replaces the search icon), trailing (icon buttons or a 30px avatar <img>). Parts: bar, input, view. CSS: --md-search-{container,view-container,dropdown-container,scrim}-color, --md-search-{input-text,supporting-text,leading-icon,trailing-icon}-color.

<md-search-app-bar> is the search app bar: an md-search between a navigation button (slot="leading") and actions (slot="trailing"), 64px tall, the search bar 360–720px wide and centred. scroll-behavior="enter-always" hides it as content scrolls down and brings it back on scroll up, switching it to surface container (and the search bar to surface container highest) while content is under it; scroll-target names the scrolling element, as on md-app-bar. When its search expands full-screen, the buttons slide away and come back as it collapses. Part: container. CSS: --md-search-app-bar-{container,scrolled-container,search-container,scrolled-search-container,leading-icon,trailing-icon}-color.

Bottom sheet

<md-bottom-sheet modal id="share">
  <md-list>
    <md-list-item type="button"><md-icon slot="leading">link</md-icon>Copy link</md-list-item>
  </md-list>
</md-bottom-sheet>
<md-button onclick="share.open = true">Share</md-button>

<div style="position: relative; height: 100vh">
  <main>…</main>
  <md-bottom-sheet>…</md-bottom-sheet>  <!-- standard: rests at the bottom, peeking 56px -->
</div>

Secondary content anchored to the bottom of the screen, on surface container low with 28px top corners and a drag handle. It's full width up to 640px; on windows wider than 640px it keeps 56px from the sides and top, otherwise 72px from the top, and its content scrolls once it's that tall. It drags and flicks between its stops (released past 56px, or flicked faster than 125px/s, it moves on to the next), and while it's partially expanded a swipe up on its content expands it before the content scrolls; at the top of the content, a swipe down collapses it.

| Prop | Notes | Default | |---|---|---| | modal | opens over the page with a scrim (scrim click and Escape dismiss it); otherwise a standard sheet at the bottom of its positioned container | false | | open | shown; also show() / hide() | false | | state | hidden, partially-expanded or expanded; set it to move there; also expand(), partialExpand() | – | | skip-partially-expanded | no partial stop: opens straight to full height | false | | peek-height | standard: px showing while partially expanded | 56 | | hideable | standard: can be swiped (or set) all the way down | false | | no-drag-handle | leaves out the handle | false | | label | accessible name | 'Bottom sheet' |

A modal sheet opens to its partial stop, which is half its height but at most half the window, then expands. Pressing the handle expands a partial sheet and dismisses (modal) or collapses (standard) an expanded one; Escape takes an expanded modal sheet back to its partial stop first. Events: mdOpen, mdClose (hidden), mdStateChange ({state}, when it settles). Parts: container, handle. CSS: --md-bottom-sheet-{container,drag-handle,scrim}-color. List items inside get a transparent container.

Side sheet

<div style="display: flex; height: 100vh">
  <main style="flex: 1">…</main>
  <md-side-sheet open divider headline="Details">…</md-side-sheet>
</div>

<md-side-sheet modal back-button headline="Filters" id="filters">
  …
  <md-button slot="actions" variant="filled">Apply</md-button>
  <md-button slot="actions" variant="outlined">Cancel</md-button>
</md-side-sheet>

Supplementary content along the side of the window: a header (headline and close button, and an optional back button), scrolling content and an optional row of actions under a divider; 256px wide (--md-side-sheet-width, at most 400px). A standard sheet (surface) sits beside the page and its width follows the slide, so the page moves aside as it opens; a modal one (surface container low, 16px inner corners, elevation 1) opens over a scrim. Either can be swiped back towards its edge: a swipe faster than 500px/s or past halfway closes it.

| Prop | Notes | Default | |---|---|---| | open | shown; also show(), hide(), toggle() | false | | modal | over the page with a scrim (close button, scrim click and Escape close it) | false | | detached | 16px in from the edges, 16px corners | false | | position | end or start edge | 'end' | | headline | header text (or slot="headline") | '' | | back-button | back arrow before the headline; fires mdBack | false | | no-close-button | leaves out the close button | false | | divider | standard: a line along the inner edge | false | | close-label, back-label | button labels | 'Close', 'Back' |

Events: mdOpen, mdClose (closed), mdBack. Slots: default (content), headline, actions. Parts: container, header, actions. CSS: --md-side-sheet-{width,container-color,headline-color,scrim-color}.

Card

<md-card>…</md-card>
<md-card variant="elevated" style="padding: 16px">…</md-card>
<md-card variant="outlined" clickable>…</md-card>
<md-card href="/trips/kyoto">…</md-card>

| Prop | Notes | Default | |---|---|---| | variant | filled (surface container highest), elevated (surface container low + shadow) or outlined (surface + 1px outline variant border) | filled | | clickable | the whole card is a button: focusable, Enter/Space, ripple, hover/press elevation; listen for click | false | | href target rel | the whole card is a link (implies clickable); preventDefault() on its click cancels navigation | – | | disabled | for clickable cards; controls inside the card stay enabled | false | | dragged | dragged elevation, for cards you let people drag | false |

Children stack in a column and are clipped to the 12px corners, so media can sit flush; pad the card or its children. Buttons and other controls inside a clickable card keep their own presses (and their clicks still bubble through the card, so check event.target if you need to tell them apart). CSS: --md-card-container-color, --md-card-content-color, --md-card-outline-color, --md-card-shape.

Carousel

<md-carousel label="Destinations" item-width="186" style="padding-inline: 16px">
  <md-carousel-item><img src="kyoto.jpg" alt="Kyoto" /></md-carousel-item>
  <md-carousel-item><img src="lisbon.jpg" alt="Lisbon" /></md-carousel-item>
  …
</md-carousel>

| Prop | Notes | Default | |---|---|---| | layout | multi-browse (large, medium and small items), hero (one large item, with small ones beside it) or uncontained (same-size items that run off the edge) | multi-browse | | item-width | preferred width of the large items (the exact width for uncontained); hero defaults to the full width | 186 | | alignment | hero only: center (between two small items) or start | center | | item-spacing | gap between items, px | 8 | | min-small-item-width / max-small-item-width | size range of the small items | 40 / 56 | | current-item | the item at (or nearest) its resting position; setting it scrolls there | 0 | | label | accessible name | – |

Methods: scrollToItem(i), animateScrollToItem(i). Event: mdChange (detail.currentItem). People drag or swipe it (multi-browse and hero move at most one item per fling and settle on an item; uncontained coasts to a stop), scroll it sideways with a trackpad or Shift+wheel, or focus it and use the arrow keys, Home and End. Height defaults to 205px; set height on the carousel. Horizontal padding only moves where the first and last items rest, as Compose's content padding does. Each <md-carousel-item> lays its content out at the full item size and reveals it through a rounded mask (--md-carousel-item-shape, 28px), so images should fill it (<img> and <video> get object-fit: cover). Content can follow the mask with the custom properties the carousel sets on each item: --md-carousel-item-mask-start and --md-carousel-item-mask-size (px) and --md-carousel-item-progress (0 at the smallest size, 1 at the largest), e.g. to pin a caption to the visible edge and fade it in.

Chips

<md-chip><md-icon slot="icon">event</md-icon>Add to calendar</md-chip>
<md-chip type="filter" selected>Vegetarian</md-chip>
<md-chip type="input" removable><img slot="avatar" src="ada.jpg" alt="" />Ada</md-chip>
<md-chip type="suggestion">Sounds good</md-chip>

| Prop | Notes | Default | |---|---|---| | type | assist (an action), filter (toggles; shows a check while selected), input (an entered item), suggestion | assist | | elevated | raised, with a shadow instead of an outline (not input chips) | false | | selected | filter and input chips; a filter chip toggles it on click and fires input, change and mdChange | false | | removable / remove-label | input chips: a remove button that fires mdRemove (cancelable) and then removes the chip | false / Remove | | disabled | | false | | pressed | holds the pressed shape and state layer (an open <md-menu> sets it on its anchor) | false | | name / value | filter chips are form-associated: submitted while selected | – / on |

Slots: default (label), icon (18px leading icon; a filter chip swaps it for the check while selected), avatar (input chips, 24px round), trailing-icon. Filter and input chips are announced as checkboxes.

Divider

<md-divider></md-divider>
<md-divider inset-start></md-divider>
<md-divider vertical></md-divider>

A 1px line in outline-variant, filling the width (or with vertical, the height) it's given. inset-start, inset-end and inset (both) inset it 16px (--md-divider-inset). Announced as a separator. CSS: --md-divider-color, --md-divider-thickness.

List

<md-list>
  <md-list-item>
    <md-icon slot="leading">person</md-icon>
    Ada Lovelace
    <span slot="supporting">Analyst</span>
    <span slot="trailing">100+</span>
  </md-list-item>
  <md-divider></md-divider>
  <md-list-item type="button">Settings</md-list-item>
</md-list>

<md-list variant="segmented">
  <md-list-item type="checkbox" selected>
    <md-icon slot="leading">wifi</md-icon>Wi-Fi<md-switch slot="trailing"></md-switch>
  </md-list-item>
  <md-list-item type="radio"><md-icon slot="leading">dark_mode</md-icon>Dark</md-list-item>
</md-list>

<md-list>: variant standard (default) or segmented (separate items 2px apart, the outer corners of the first and last rounded to 16px, surface-container items), and reorderable. The M3 guidelines use segmented gaps for contained lists and groups (settings, selections) and keep dividers for uncontained lists; the standard style has no gaps, so selected rows meet. Arrow keys, Home and End move focus between interactive items. Announced as a list (a radio group if it holds radio items).

| <md-list-item> prop | Notes | Default | |---|---|---| | type | text (not interactive), button (listen for click), checkbox (toggles selected), radio (selects itself, unselects the other radio items in its list) | text | | href / target / rel | a link item (a real <a>) | – | | selected | checkbox and radio items fire input, change and mdChange when the user changes it; on other items it just shows the selected colours | false | | disabled | | false | | dragged | dragged colours (tertiary container) and elevation; a reorderable list sets it while dragging | false | | segment | none / only / first / middle / last; set by a segmented <md-list> | none | | expandable / expanded | a row that shows the items in its children slot while expanded; clicking it toggles expanded and fires mdExpand | false | | swipe-primary-action | with swipe actions: none, indirect (swipe further past the open actions) or direct (one swipe); a full swipe clicks the outermost action | none | | long-press | holding the row (400ms), a right click or the context-menu key fires mdLongPress, and the click that follows is skipped | false |

Methods: setSwipeState(state, side?, animate?) (closed, open, primary; side start or end), getSwipeState(), dismiss() (fades the item out, closes the gap and removes it). Events: mdChange, mdExpand, mdSwipe ({ state, side } when a swipe settles), mdLongPress.

<!-- Expand and collapse -->
<md-list variant="segmented">
  <md-list-item expandable>
    <md-icon slot="leading">folder</md-icon>Documents
    <md-list-item slot="children" type="checkbox">Work<md-checkbox slot="trailing"></md-checkbox></md-list-item>
    <md-list-item slot="children" type="checkbox">Receipts<md-checkbox slot="trailing"></md-checkbox></md-list-item>
  </md-list-item>
</md-list>

<!-- Swipe to reveal -->
<md-list-item type="button" swipe-primary-action="indirect">
  Mia Chen
  <md-icon-button slot="trailing" label="More actions"><md-icon>more_horiz</md-icon></md-icon-button>
  <md-list-action slot="start-actions" variant="tonal" label="Mark as read"><md-icon>mark_email_read</md-icon></md-list-action>
  <md-list-action slot="end-actions" variant="tonal" label="Snooze"><md-icon>schedule</md-icon></md-list-action>
  <md-list-action slot="end-actions" label="Archive"><md-icon>archive</md-icon></md-list-action>
</md-list-item>

<!-- Reorder -->
<md-list variant="segmented" reorderable>
  <md-list-item>Golden hour<md-icon slot="trailing" drag-handle>drag_handle</md-icon></md-list-item>
  <md-list-item>Paper planes<md-icon slot="trailing" drag-handle>drag_handle</md-icon></md-list-item>
</md-list>

Expand and collapse: the children grow in and out with a spring (the rows below move with them), the trailing expand icon turns, and the row is announced as expanded or collapsed. Swipe to reveal: <md-list-action> buttons (label, variant filled / tonal / outlined / standard) in the start-actions or end-actions slot are revealed by dragging the row (touch or mouse), or with ← / → on the focused row. The guidelines ask for another way to reach hidden actions, such as a "more" button that calls setSwipeState('open', 'end'). Don't leave a row fully swiped: handle the primary action by removing the row (dismiss()) or closing it. Reorder: in a reorderable list, drag an item by its drag-handle element (which also becomes focusable: Alt + ↑/↓ moves the item). Other items make room, a drop zone marks the slot, and on release the list moves the item in the page and fires mdReorder ({ item, from, to }). Near the top or bottom of the window the page scrolls.

Slots: default (headline), overline, supporting, leading, trailing. The item is 56, 72 or 88px tall for one, two or three lines (overline plus supporting text, or supporting text that wraps), centring its content until it is three lines tall. Corners spring from 4px at rest to 12px on hover and 16px when pressed, focused, selected or dragged. In checkbox and radio items, an <md-checkbox>, <md-switch> or native checkbox/radio in the leading or trailing slot mirrors selected and leaves input to the row (the row is announced as a switch when it holds a switch). A switch can still be tapped or dragged directly; the row takes over its events and fires its own. Other controls in a row (e.g. an <md-icon-button>) keep their own clicks. CSS: --md-list-item-container-color, --md-list-item-selected-container-color, --md-list-item-{headline,supporting,overline,leading,trailing}-color, ::part(item).

Menu

<md-icon-button id="more" label="More options"><md-icon>more_vert</md-icon></md-icon-button>
<md-menu anchor="more">
  <md-menu-item><md-icon slot="leading">content_copy</md-icon>Copy<span slot="trailing">⌘C</span></md-menu-item>
  <md-menu-item disabled>Redo</md-menu-item>
  <md-divider></md-divider>
  <md-menu-item>
    Align
    <md-menu slot="submenu">
      <md-menu-item type="radio" selected>Left</md-menu-item>
      <md-menu-item type="radio">Right</md-menu-item>
    </md-menu>
  </md-menu-item>
</md-menu>

<md-menu anchor="photo" context>…</md-menu>  <!-- right-click / long press, at the pointer -->

<md-menu> opens from the element whose id is in anchor: clicking it toggles the menu, and ↓ / ↑ on it open the menu with the first / last item focused. While it's open, a button, icon button or chip anchor stays pressed (pressed), and a split button opens it from its arrow and shows it checked (expanded). With context it opens instead on a right-click or long press, at the pointer. It renders in the top layer (above dialogs), grows out of its anchor, and places itself below the anchor, else above, else against the window edge, keeping 48px from the window's top and bottom (taller menus scroll). position picks another side (above, start, end, left, right); offset-x / offset-y nudge it. quick opens and closes it without animating. Methods: show({ x, y, focus }), close(), toggle(); open reflects the state. Events: mdOpen and mdClose (on the menu itself), and mdSelect ({ item, value }, bubbling, so it also reports a submenu's items).

Menus are vertical (the expressive style) by default: rounded, color="standard" (surface) or "vibrant" (tertiary). variant="baseline" gives the square M3 baseline menu. Wrap items in <md-menu-group label="…">s to split a vertical menu into groups 2px apart; once a group or submenu has been hovered, the others' corners tighten to show which is active.

<md-menu-item> slots: default (label), leading, selected-leading (the leading icon while selected), trailing (an icon or shortcut text), supporting, and submenu (an <md-menu>, which opens on hover, click, Enter / Space or →, and gets an arrow). Props: type (item, checkbox, radio), selected, disabled (still focusable), value, keep-open, href. Choosing an item closes the menu, except checkbox items and keep-open ones; radio items in one group (or menu) are exclusive. Selectable items without icons get a check that expands in when selected. Keys: ↑ / ↓ / Home / End, letters (type-ahead), → / ← for submenus, Escape, and Tab (which closes the menu); focus returns to the anchor. CSS: --md-menu-container-color, --md-menu-item-{label,icon,supporting}-color, --md-menu-item-selected-{container,content}-color.

Loading indicator

<md-loading-indicator></md-loading-indicator>
<md-loading-indicator contained></md-loading-indicator>
<md-loading-indicator value="0.4" label="Uploading photo"></md-loading-indicator>

A 48px morphing shape for short waits. Indeterminate (no value): it morphs through seven Material shapes every 650ms on a bouncy spring, turning a quarter with each and slowly rotating. With value (0 to max, default 1) a circle morphs into a soft burst as it fills. contained puts it on a round primary-container background. label is its accessible name (default "Loading"). CSS: --md-loading-indicator-color, --md-loading-indicator-container-color. The shapes are exported too: MaterialShapes, RoundedPolygon, Morph, cubicsToPath.

Progress indicators

<md-linear-progress value="0.4"></md-linear-progress>
<md-linear-progress></md-linear-progress>
<md-linear-progress wavy value="0.6"></md-linear-progress>
<md-circular-progress value="0.4" thickness="8"></md-circular-progress>
<md-circular-progress wavy></md-circular-progress>

| Prop | Notes | Default | |---|---|---| | value / max | progress; leave value out for an indeterminate indicator. Changes animate | – / 1 | | wavy | the expressive wave (flattens below 10% and above 95%) | false | | thickness | stroke width in px; the container grows with it (linear: thickness, or thickness + 6 wavy; circular: 36 / 44 + thickness) | 4 | | label | accessible name | – |

Linear indicators are 240px wide by default; set a CSS width to change it. CSS: --md-progress-color, --md-progress-track-color. Both are announced as progress bars, with their value when determinate. They only animate while on screen.

Badge

<md-icon-button label="Mail, 3 unread">
  <md-badged><md-icon>mail</md-icon><md-badge slot="badge" value="3"></md-badge></md-badged>
</md-icon-button>
<md-badge></md-badge>              <!-- dot -->
<md-badge>New</md-badge>           <!-- short text -->

<md-badge>: empty is a 6px dot; value shows a count (above max, default 999, it shows 999+), or put short text inside. CSS: --md-badge-color (error), --md-badge-text-color (on error). <md-badged> pins the slot="badge" badge to the top-end corner of its content (usually an md-icon). Badges don't take presses. A labelled button's label is what screen readers announce, so include the count there.

Switch

<label><md-switch name="wifi" checked></md-switch> Wi-Fi</label>
<md-switch aria-label="Dark mode" icons></md-switch>
<md-switch aria-label="Sync">
  <svg slot="checked-icon" …/>
</md-switch>

| Prop | Notes | Default | |---|---|---| | checked | reflected | false | | disabled | also follows a disabled <fieldset> | false | | icons | built-in check / close thumb icons | false | | required | form validation: must be on | false | | name / value | submitted only when checked | – / on |

Behaves like a native checkbox: focusable host with role="switch" (via ElementInternals), so <label>, aria-label and aria-labelledby work directly. Fires input, change and mdChange { checked } when the user toggles it by tap, drag, Space/Enter or label click; preventDefault() on click cancels a toggle. Slots: icon, checked-icon. Parts: track, thumb. CSS: --md-switch-{checked,unchecked}-{track,thumb,pressed-thumb,icon}-color, --md-switch-unchecked-outline-color, --md-switch-ripple-color (its alpha is used; defaults to 12% black / 20% white by color-scheme).

Checkbox

<label><md-checkbox name="tos" required></md-checkbox> I accept</label>
<md-checkbox aria-label="Select all" indeterminate></md-checkbox>

| Prop | Notes | Default | |---|---|---| | checked | reflected | false | | indeterminate | dash; cleared when the user toggles (like a native checkbox) | false | | error | error colours, sets aria-invalid | false | | disabled | also follows a disabled <fieldset> | false | | required | form validation: must be checked. Submitting it unchecked shows error until it's checked, and the browser's message in a tip above it (not the browser's popup) | false | | name / value | submitted only when checked | – / on |

Same native-control behaviour as the switch (role="checkbox", aria-checked="mixed" when indeterminate, labels, input / change / mdChange { checked, indeterminate }, Space/Enter). Parts: container, checkmark. CSS: --md-checkbox-checked-color, --md-checkbox-checkmark-color, --md-checkbox-unchecked-outline-color, --md-checkbox-error-color, --md-checkbox-on-error-color.

Radio button

<label><md-radio name="size" value="small"></md-radio> Small</label>
<label><md-radio name="size" value="large" checked></md-radio> Large</label>

| Prop | Notes | Default | |---|---|---| | checked | reflected; selecting one unselects the rest of its group | false | | name | radios with the same name in the same form (or document) are one group | – | | value | submitted when selected | on | | disabled | also follows a disabled <fieldset> | false | | required | form validation: one radio in the group must be selected | false |

Behaves like <input type="radio">: role="radio", labels, input / change / mdChange { checked, value } when the user selects it (clicking a selected radio does nothing), Space/Enter, arrow keys moving the selection through the group (skipping disabled ones, wrapping), and one Tab stop per group (the selected radio, or the first). In an <md-list-item type="radio"> the row does the selecting. Part: container. CSS: --md-radio-selected-color, --md-radio-unselected-color.

Slider

<md-slider aria-label="Volume" value="60" labeled></md-slider>
<md-slider aria-label="Brightness" value="40" step="10"></md-slider>
<md-slider aria-label="Exposure" min="-50" max="50" centered></md-slider>
<md-slider aria-label="Level" orientation="vertical" bottom-to-top size="m" style="height: 300px"></md-slider>
<md-slider aria-label="Volume" size="m" value="60"><md-icon slot="icon">volume_up</md-icon></md-slider>

| Prop | Notes | Default | |---|---|---| | value | coerced into min…max and snapped to step | 0 | | min / max | | 0 / 100 | | step | 0 = continuous (Compose steps = 0); a step draws tick marks | 0 | | centered | active track grows from the centre (CenteredTrack) | false | | orientation | horizontal or vertical (vertical defaults to 240px tall; set height) | horizontal | | bottom-to-top | vertical: minimum at the bottom (Compose's default topToBottom puts it at the top) | false | | size | xs s m l xl (track 16/24/40/56/96, handle 44/44/52/68/108) | xs | | labeled | value indicator above the handle while pressed, dragged, hovered or keyboard-focused | false | | valueLabel | JS property: (value) => string for the label and aria-valuetext | – | | disabled / name | form-associated; submits value, resets, follows a disabled <fieldset> | – |

Inset icon: put an icon in slot="icon" on an m, l or xl slider (24, 24 and 32px; the spec has none for xs/s, and none on a centered slider). It sits 10px inside the start of the active track, and moves to the start of the inactive track while the active one is too short to hold it. Its colour follows the part it's on: --md-slider-active-icon-color (on-primary) and --md-slider-inactive-icon-color (on-secondary-container). Part: icon.

A press jumps the thumb to the pointer and drags from there (MDC BaseSlider); a touch inside a scrolling container waits for 8px along the track first, so scrolling past it doesn't move it. Keys: arrows (horizontal sliders also take Up/Down), Page Up/Down (10% or 1–10 steps), Home/End. Events: input + mdInput { value } on every change, change + mdChange when an interaction ends with a new value. Parts: track, handle, label, icon. CSS: --md-slider-{active,inactive}-track-color, --md-slider-handle-color, --md-slider-{active,inactive}-tick-color, --md-slider-{active,inactive}-icon-color, --md-slider-label-{container,text}-color.

Range slider

<md-range-slider aria-label="Price" max="500" value-start="120" value-end="380" labeled></md-range-slider>
<md-range-slider aria-label="Hours" max="24" step="2" value-start="8" value-end="18"></md-range-slider>

Two thumbs selecting a range, drawn like <md-slider> (inactive track and a stop indicator on both sides, gaps around both handles). It takes the slider's min, max, step, size, orientation, bottom-to-top, labeled, valueLabel and disabled, plus:

| Prop | Notes | Default | |---|---|---| | value-start / value-end | the range; each is coerced to the other, so the thumbs never cross (out-of-order values are swapped on load) | min / max | | aria-label-start / aria-label-end | accessible names of the two thumbs | Range start / Range end | | name | form-associated: submits two entries under name, start then end | – |

Each thumb is a focusable slider with its own keys (as <md-slider>, limited by the other thumb); the host is a group, labelled with aria-label or aria-labelledby. A press grabs the closer thumb and jumps it to the pointer; when the thumbs sit on the same value, the press waits until the pointer has moved 8px and takes the thumb on that side. Events: input + mdInput and change + mdChange, all with { valueStart, valueEnd }. Parts: track, handle, thumb (the focus ring), label. Same CSS properties as <md-slider>. No inset icon (MDC allows track icons only with one thumb).

Details

<md-details summary="Code" icon="code">
  <pre><code>…</code></pre>
</md-details>

A disclosure, like <details>: an <md-button> (any variant, default text) with a chevron that turns, and content that expands and shrinks with a spring while fading. Not an M3 or Compose component; it's the library's own, built from its pieces. Props: open, summary (or the summary slot), icon (a Material Symbols name), variant, disabled. Fires toggle and mdToggle ({open}) when the user opens or closes it. The closed content is inert and out of the layout. Parts: button, body. CSS: --md-details-content-radius rounds the clip the content moves in, so rounded content keeps its corners mid-animation.

Ripple

<a class="card" href="/trip" style="position: relative; border-radius: 16px">
  <md-ripple></md-ripple>
  …
</a>

Adds the press ripple and the hover (8%) / keyboard-focus (10%) highlight to a clickable surface you build yourself. Put it inside the surface, which must be positioned; it fills it and inherits its border-radius. It's visual only: clicks, focus and keys stay with the surface.

| Prop | Notes | Default | |---|---|---| | for | id of the element to attach to instead of the parent | – | | disabled | no ripple or highlight (also off while the surface is :disabled or aria-disabled="true") | false |

Presses on controls inside the surface (buttons, links, inputs, switches, sliders, …, or another surface with its own ripple) don't ripple the outer surface. Touch presses wait 100ms, so scrolling past a surface doesn't flash it. CSS: --md-ripple-color (defaults to the surface's text colour). Tip: add -webkit-tap-highlight-color: transparent to the surface on mobile.

Date picker

<md-date-picker-dialog id="due" value="2026-10-16"></md-date-picker-dialog>
<md-date-picker-dialog range></md-date-picker-dialog>
<md-date-picker value="2026-10-16" name="due"></md-date-picker>

| Prop | Notes | Default | |---|---|---| | value | the selected date, "YYYY-MM-DD" (like <input type="date">) | – | | range / start / end | pick a range instead: two clicks set the start, then the end (a date before the start starts over) | false | | mode | picker (calendar) or input (typed, in the locale's numeric format, e.g. MM/DD/YYYY); the header button toggles it | picker | | hide-mode-toggle | | false | | min / max | earliest / latest selectable date | – | | first-year / last-year | the calendar's years | 1900 / 2100 | | isDateSelectable | JS property, (date) => boolean, for any other dates that can't be picked | – | | strings | JS property: override any label or announcement | English | | name / required | inline picker only: form-associated; a range submits start and end under the same name | – |

<md-date-picker> fires change and mdChange (detail.value, or detail.start / detail.end) as the selection changes. <md-date-picker-dialog> edits a copy: show() opens it, OK commits to value (or start / end) and fires mdConfirm; Cancel, Escape or an outside click fire mdCancel; mdClose follows either. OK is enabled once there's a date (both ends for a range). Swipe or drag between months (or use the arrows, a trackpad, or Page Up / Page Down), tap the month to pick a year, and move between days with the arrow keys. Weekday order, names and the typed format follow the page's lang. The inline range picker is 568px tall in calendar mode (set height to change it); its text fields take only the space they need, and the height follows the switch between the two. For a field with a calendar below it (the docked date picker), see <md-date-field>: it's what the M3 guidelines recommend on tablets and desktops (there's no landscape modal date picker in M3). CSS: --md-date-picker-container-color, --md-date-picker-years-color (behind the year list; set it when the container is transparent).

Text field

<md-text-field label="Email" type="email" name="email" required></md-text-field>
<md-text-field variant="outlined" label="Amount" type="number" prefix-text="$"></md-text-field>
<md-text-field label="Search"><md-icon slot="leading-icon">search</md-icon></md-text-field>
<md-text-field label="Bio" rows="3" maxlength="140"></md-text-field>

| Prop | Notes | Default | |---|---|---| | variant | filled or outlined | filled | | label / placeholder | the label floats when focused or filled; the placeholder shows while focused and empty | – | | value, type, name, required, pattern, minlength, maxlength, min, max, step, autocomplete, inputmode, enterkeyhint, readonly, disabled | as on <input>; form-associated with native constraint validation | – | | supporting-text | helper text below | – | | error / error-text | error colours; error-text replaces the supporting text. A failed validation (submitting the form, reportValidity()) turns them on with the browser's message instead of showing the browser's popup; they then follow the value as you type, until the form resets | false | | prefix-text / suffix-text | e.g. "$", "kg" (shown once the label floats) | – | | rows | more than 1 makes a multi-line text area (it grows with its text) | 1 | | maxlength | also shows an n/max counter | – |

Slots: leading-icon, trailing-icon (24px icons or icon buttons, in 48px boxes). Events: input and mdInput as the user types, change when the edit is committed. Methods: checkValidity() (silent, like <input>'s), reportValidity() (shows the error and focuses), select(). 280px wide by default; set width.

Date field (docked date picker)

<md-date-field label="Check-in" name="checkin"></md-date-field>

The docked date picker, for tablets and desktops: a text field where the date can be typed (in the locale's numeric pattern, shown as the supporting text; checked on Enter or when the field loses focus) and a calendar button. The calendar, <md-docked-date-picker>, drops down 8px under the field (above it if there's no room): ‹ month ▾ › and ‹ year ▾ › controls with month and year lists, six week rows including the neighbouring months' days, and Cancel / OK. OK sets the date; Cancel, Escape or a press outside leave it. Takes label, value ("YYYY-MM-DD"), variant (outlined by default), supporting-text, min, max, first-year, last-year, isDateSelectable, strings (the calendar's labels plus invalidPattern / invalidNotAllowed), name, required, disabled; fires change and mdChange; show() / close(). <md-docked-date-picker> also works on its own: value, the same limits, hide-actions; events mdChange (a day was picked), mdConfirm, mdCancel. CSS: --md-docked-date-picker-container-color.

Time picker

<md-button id="open">Pick a time</md-button>
<md-time-picker-dialog id="dlg" value="07:30"></md-time-picker-dialog>
<script>
  open.onclick = () => dlg.show();
  dlg.addEventListener('mdConfirm', (e) => console.log(e.detail.value)); // "HH:MM"
</script>

<!-- or inline -->
<md-time-picker name="alarm" value="21:40" hour-cycle="24"></md-time-picker>

<md-time-picker>

| Prop | Notes | Default | |---|---|---| | value | "HH:MM", 24-hour (like <input type="time">) | 00:00 | | hour-cycle | 12 or 24 | the locale's | | mode | dial (clock), input (keyboard) or scroll (wheels; always vibrant-styled) | dial | | variant | standard or vibrant (Compose's TimePicker(state, shapes)) | standard | | mode-toggle | input/scroll: AM/PM + a scroll ⇄ keyboard toggle beside the fields, for use without a dialog (always vibrant-styled, as in Compose) | false | | selection | hour or minute | hour | | orientation | vertical, horizontal, or auto (Compose's rule: horizontal when the viewport is wider than tall) | auto | | strings | JS property: override any label / announcement (AM/PM default to the locale's) | English | | name | form-associated; submits value; out-of-range typing makes it invalid | – | | input-valid | read-only: false while typed input is out of range | true |

Events: mdInput (every step, incl. drags and wheel scrolling), mdChange (committed), mdValidityChange { valid }, plus native input / change. Parts: dial, hour, minute, period.

<md-time-picker-dialog>: open, value (updated on OK), variant, mode (dial or scroll also picks which toggle it offers), hour-cycle, orientation, hide-mode-toggle, headline, confirm-label, cancel-label, toggle-to-*-label, strings; show() / close(); events mdConfirm { value, hour, minute }, mdCancel, mdClose { returnValue }. OK is disabled while typed input is invalid. In landscape (horizontal dial) it is sized like Flutter's M3 dialog (342px of content in 24px padding) rather than taking the whole height; under 300px tall the dial gives way to keyboard input. Switching between the dial and keyboard input is a shared-element transition: the hour and minute boxes, separator, AM/PM and buttons move and resize into place, the dial or the field labels fade, and the dialog springs to its new size.

<md-scroll-field> (Compose ScrollField): an endless wheel. count, value (0 … count − 1), offset (shown number = value + offset), min-digits, label, value-text ({n} placeholder); events mdInput (live) / mdChange (settled). Drag, fling, wheel, Up/Down, tap an item.

Dialog, icon button & tooltip

Full-screen dialog: <md-dialog fullscreen> puts the headline in a 56px header after a close button (it dismisses like Escape, firing mdCancel; close-label names it) with the actions (e.g. Save) at its end; the content scrolls between 24px margins, with a divider under the header once it has scrolled; an optional bottom-actions slot adds a 56px bottom bar. Under 600px wide it fills the window and slides up as it appears; wider, it's a 560px-wide, nearly full-height dialog.

<md-dialog fullscreen>
  <span slot="headline">New event</span>
  <md-button slot="actions" variant="text" onclick="this.closest('md-dialog').close('save')">Save</md-button>
  …form…
</md-dialog>
<md-dialog id="d">
  <svg slot="icon" …/>
  <span slot="headline">Delete draft?</span>
  This draft will be permanently deleted.
  <md-button slot="actions" variant="text" onclick="d.close('cancel')">Cancel</md-button>
  <md-button slot="actions" variant="text" onclick="d.close('delete')">Delete</md-button>
</md-dialog>

<md-tooltip text="Settings">
  <md-icon-button label="Settings" variant="tonal" size="m" shape="square"><svg …/></md-icon-button>
</md-tooltip>

<md-dialog>: open, persistent (outside clicks don't dismiss), show(), close(returnValue); events mdOpen, mdCancel (cancelable), mdClose { returnValue }. Built on the native modal <dialog> (top layer, focus trap, Escape, focus restore) and locks page scroll while open. CSS: --md-dialog-container-color, --md-dialog-padding (24px), --md-dialog-max-width (560px), --md-dialog-height (auto), --md-dialog-margin (least space around it, 24px). With animate-resize, content that changes size while the dialog is open (a picker switching modes, say) makes the container spring to its new size instead of jumping; leave it off for content that animates its own size. --md-dialog-content-overflow (default auto) sets the content area's overflow, e.g. visible while your own transition moves things across it.

On-screen keyboards: an open dialog keeps itself centred in the visible part of the window (visualViewport) and glides to its new place when a keyboard opens or closes, so a focused field (e.g. a time or date picker's input mode) stays in view on every browser. For Chrome on Android, also add interactive-widget=resizes-content to your viewport meta tag so the page itself resizes for the keyboard instead of leaving room to pan underneath it: <meta name="viewport" content="width=device-width, initial-scale=1, interactive-widget=resizes-content">.

<md-icon-button>

| Prop | Values | Default | |---|---|---| | label | accessible name (required) | – | | variant | standard filled tonal outlined | standard | | size | xs (32) s (40) m (56) l (96) xl (136) | s | | shape | round square | round | | width | narrow uniform wide | uniform | | toggle / selected | toggle button; selected swaps round ⇄ square | false | | disabled | | false | | pressed | holds the pressed shape and state layer (an open <md-menu> sets it on its anchor) | false | | href / target / rel | renders a real link (<a>) instead of a button, e.g. to open a page; a link can't be a toggle | – |

Press springs the corners to the pressed shape; sizes under 48px keep a 48px touch target. Event mdChange { selected } on toggles. CSS: --md-icon-button-icon-color, --md-icon-button-container-color.

<md-tooltip text="…"> wraps its anchor: hover (mouse), 400ms long-press (touch, without clicking) or keyboard focus (1.5s). Rendered as a popover, above dialogs. show(duration?) / hide(). position: above (default), below, start, end, left or right, flipped when there's no room.

<md-rich-tooltip subhead="Shared album" text="Anyone with the link can add photos.">
  <md-icon-button label="Album sharing"><md-icon>group</md-icon></md-icon-button>
  <md-button slot="actions" variant="text">Manage</md-button>
</md-rich-tooltip>

<md-rich-tooltip> has the same triggers, position, show() and hide(), but shows a card:

  • Content: subhead and text (or slot="subhead" / slot="text"), and up to two buttons in slot="actions".
  • Look: surfaceContainer, 12px corners, 320px at most.
  • persistent: on by default when there are actions. It then stays after the pointer leaves or a long press ends, until a press outside, Escape, or focus leaving it.
  • Keyboard: while it shows, Tab moves from the anchor into its actions.
  • Actions: pressing one closes it.
  • Screen readers: it's announced when it shows.
  • Colour: --md-rich-tooltip-container-color.

Snackbar

<md-snackbar-host id="snacks"></md-snackbar-host>
const result = await snacks.show({ message: 'Photo deleted', actionLabel: 'Undo' });
if (result === 'action-performed') restorePhoto();

<md-snackbar-host> shows snackbars one at a time at the bottom of the window (position: fixed; restyle the host to lift it above a bottom bar or keep it inside a container).

  • show(options) takes a string or { message, actionLabel?, withDismissAction?, actionOnNewLine?, duration? }. It queues behind any snackbar already showing and resolves to 'action-performed' or 'dismissed'. dismiss() ends the current one.
  • duration is 'short' (4s), 'long' (10s), 'indefinite' or a number of ms. It defaults to 'short', or to 'indefinite' when there's an action.
  • The timeout pauses while the pointer is over the snackbar or focus is inside it.
  • Enter and exit: a fade plus a scale from 0.8. The next snackbar fades in over the leaving one.
  • Snackbars are announced through a polite live region.

<md-snackbar> is the snackbar on its own, static: action-label, with-dismiss-action, action-on-new-line and dismiss-label ("Dismiss"). The message is the element's text. It fires mdAction and mdDismiss. It fills the available width up to 600px of content and is 48px tall for one line, 68px for two. Colours: --md-snackbar-container-color, --md-snackbar-content-color, --md-snackbar-action-color, --md-snackbar-dismiss-action-color.

Toolbars

<md-toolbar scroll-behavior="exit-always">
  <md-icon-button label="Archive"><md-icon>archive</md-icon></md-icon-button>
  <md-icon-button label="Delete"><md-icon>delete</md-icon></md-icon-button>
</md-toolbar>

<md-floating-toolbar color="vibrant" scroll-behavior="collapse">
  <md-icon-button label="Undo" slot="leading"><md-icon>undo</md-icon></md-icon-button>
  <md-icon-button label="Add" variant="filled"><md-icon>add</md-icon></md-icon-button>
  <md-icon-button label="More" slot="trailing"><md-icon>more_vert</md-icon></md-icon-button>
</md-floating-toolbar>

<md-toolbar> (docked, replaces the bottom app bar):

  • 64px tall with 16px side padding, plus the bottom safe area.
  • arrangement="space-between" (default) spreads the items; "center" groups them 32px apart.
  • scroll-behavior="exit-always" slides it down out of view while the content scrolls down and back while it scrolls up, then settles shown or hidden. It can also be dragged down and back up. Position it over the content, e.g. position: fixed; bottom: 0.

<md-floating-toolbar>:

  • A 64px pill with 8px padding and 4px between items. Place it yourself, 16px from the window's edges.
  • orientation="vertical" stacks the items.
  • leading / trailing slots: shown while expanded (default true). Collapsing shrinks them towards the middle while the toolbar stays centred on its box.
  • fab slot: an <md-fab> 8px after the toolbar (fab-position="start" for before). Collapsing folds the toolbar into the FAB, which grows from 56 to 80px. The FAB takes the toolbar's colours (primaryContainer, vibrant: tertiaryContainer), and the toolbar has a small shadow while expanded.
  • scroll-behavior:
    • "exit-always": slides it out of view, down (vertical: towards the end). It can also be dragged that way and back.
    • "collapse": collapses it after 40px of scrolling down and expands it after 40px up.
  • Keyboard focus coming into a hidden or collapsed toolbar brings it back and expands it.
  • Collapsed, it adds padding beside a wide button so the space around it is even, as Compose does.
  • The host keeps its expanded size. Hits outside the visible toolbar pass through.

Both:

  • color="standard" (surfaceContainer) or "vibrant" (primaryContainer).
  • Icon buttons inside take the toolbar's content colour, and selected toggles take the specs' container (standard: secondaryContainer; vibrant: surfaceContainer).
  • scroll-target="id" names the scrolling element; by default it's the nearest scrolling ancestor, or the window.
  • Colours: --md-toolbar-container-color / --md-toolbar-content-color, and --md-floating-toolbar-* likewise.

Tabs

<md-tabs>
  <md-tab panel="flights"><md-icon slot="icon">flight</md-icon>Flights</md-tab>
  <md-tab panel="trips"><md-icon slot="icon">luggage</md-icon>Trips</md-tab>
</md-tabs>
<div id="flights">…</div>
<div id="trips">…</div>

<md-tabs>:

  • variant:
    • primary (default): the active tab in primary, with a 3px indicator the width of its content, inset 2px each side, at least 24px, top corners rounded.
    • secondary: the active tab in onSurface, with a 2px indicator across the whole tab.
  • scrollable: tabs keep their own width (at least 90px) and start 52px in. The selected tab scrolls towards the centre.
  • selected-index.
  • Events: change and mdChange ({ index, tab }) when a press changes the selection. Cancel the tab's click to prevent it.
  • The indicator slides and resizes