Alert

Material Design 3-styled alert web component (lit-material-alert) — a persistent inline/page-level banner, distinct from the snackbar toast.

  • 2.5 KB gzipped
  • @lit-material/alert 0.0.5
  • Renders on the server

Example

Install

npm install @lit-material/alert @lit-material/tokens
import "@lit-material/alert";

Link @lit-material/tokens/css/index.css once per page for the colour, type and shape tokens. Install guide

API

<lit-material-alert>

A persistent inline/page-level banner — distinct from lit-material-snackbar, which is a transient, Popover-API-based toast that shows up temporarily and floats above content. An alert is a normal part of the page layout: it stays until the user dismisses it (or the consumer removes it), and never auto-dismisses on its own.

Properties

PropertyAttributeTypeDefaultDescription
variantvariantAlertVariant"info"
dismissibledismissiblebooleanfalse

Events

EventDescription
closeFires when dismissed via the close button. Not cancelable — see dismiss().

Slots

SlotDescription
iconOverrides the variant's default icon.
titleOptional heading, above the description. Slot exactly one element.
defaultThe alert's description/body text.
actionOptional action buttons/links. For more than one, wrap them in a single element yourself so they end up in one row.

CSS parts

PartDescription
alertThe banner (background, padding, shape).
iconThe icon container.
bodyThe title/description/action container.
closeThe dismiss button. Only rendered when dismissible.

CSS custom properties

PropertyDescription
--lit-material-alert-shapeCorner radius (default --md-sys-shape-corner-small).

Source on GitHub npm