Error Card

Error card web component: a headline, what to try next, actions, and the raw error under a collapsible Details block with a copy button.

  • 4.0 KB gzipped
  • @lit-material/error-card 1.8.0
  • Renders on the server

Example

Install

npm install @lit-material/error-card @lit-material/tokens
import "@lit-material/error-card";

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

API

<lit-material-error-card>

A failure explained: a short headline ("Connection refused"), what to try next, optional actions (Retry, Open settings), and the raw error text — an engine message, a stack, a response body — under a collapsible Details block with a copy button, so people can report it.

Properties

PropertyAttributeTypeDefaultDescription
headlineheadlinestring""What went wrong, in a few words ("Host not found").
detailsdetailsstring""The raw text (an engine message, a stack trace). Shown under Details with a copy button; none, no Details.
variantvariantErrorCardVariant"error"error or warning.
alertalertbooleanfalseAnnounce the card as it appears (role="alert").
openopenbooleanfalseWhether the Details block is open.

Events

EventDescription
toggleThe Details block opened or closed; detail: { open }.

Slots

SlotDescription
defaultWhat to try next.
actionsButtons or links (Retry, Open settings…).

CSS parts

PartDescription
cardThe container.
iconThe error or warning icon.
headlineThe headline.
toggleThe Details button.
detailsThe raw text.
copyThe Copy details button.

CSS custom properties

PropertyDescription
--lit-material-error-card-warning-colorWarning icon and border colour.
--lit-material-error-card-warning-containerWarning background.
--lit-material-error-card-details-max-heightThe Details block scrolls past this height (default 16rem).

Source on GitHub npm