mica

Example

Heads upManual popovers survive light dismiss; the X dismisses.SavedYour changes are safe.

Basic usage

<m-toast id="saved" popover="manual" variant="success" role="status">
  <button class="close" popovertarget="saved"
          popovertargetaction="hide" aria-label="Dismiss">&#x2715;</button>
  <b>Saved</b>
  <span>Your changes are safe.</span>
</m-toast>

document.getElementById(&#39;saved&#39;).showPopover()  // from your app code

API

Attributes

NameTypeDefaultDescription
popover="manual"native attributeKeeps the toast open through light dismiss and while other popovers open.
variantsuccess | warning | dangerAdds the corresponding status edge.
durationmilliseconds5000Auto-dismiss delay when toast.js is loaded. 0 makes the toast sticky.
role="status"ARIA roleRequests a polite announcement.

Content/markup contract

PartContractDefaultDescription
button.closedirect childoptionalDismisses through popovertargetaction="hide"; provide an accessible name.
btitlePrimary toast message.
span or pdescriptionoptionalMuted supporting text.

Styling/public properties

PropertyValueDefaultDescription
--toast-positionbottom-right | bottom-left | bottom-center | top-right | top-left | top-centerbottom-rightApp-level position set once on :root; every toast follows it.
:root { --toast-position: top-center }
/* bottom-right (default) | bottom-left | bottom-center
   | top-right | top-left | top-center */

Top positions stack downward and enter from above; centers are viewport-centered.

Native methods

NameTypeDefaultDescription
showPopover()methodShows an authored toast from app code.
hidePopover()methodDismisses an authored toast from app code.

toast.js

Optional and loaded on this page. Open toasts stack upward; auto-dismiss defaults to 5000ms, is disabled by duration="0", and pauses while hovered. The exported toast() helper creates the same markup, shows it, and removes it after dismissal.

import { toast } from 'mica/toast.js'

toast('Saved', { description: 'Your changes are safe.',
                variant: 'success', duration: 4000 })
ExportSignatureDefaultDescription
toast(title, { description, variant, duration })optional fieldsSpawns and returns an ephemeral m-toast. Variant accepts success, warning, or danger.

Without the module, m-toast remains an inert styling wrapper around working native manual-popover behavior.

Accessibility

Use role="status" for polite announcements and give an icon-only dismiss button an accessible name. Sticky toasts remain available until explicitly dismissed.

Browser support

Position overrides use container style queries (Baseline newly-available 2026-05). Without support, --toast-position is ignored and toasts keep the bottom-right default — plainer, not broken.

← popover & tooltiptabs →