Components
Dialogs & Alerts
Native dialog patterns — sizes, scrollable, confirmation, and stacked — plus notification banners, inline labels, and toast messages.
Dialogs
Structured Dialog
Use dialog-header, dialog-body, and dialog-footer for
a consistent header/body/footer layout.
<dialog id="my-dialog" aria-labelledby="dialog-title">
<div class="dialog-header">
<h3 id="dialog-title">Edit Profile</h3>
<button class="dialog-close" aria-label="Close">×</button>
</div>
<div class="dialog-body">
<form class="form">...</form>
</div>
<div class="dialog-footer">
<button class="btn btn-secondary">Cancel</button>
<button class="btn btn-primary">Save</button>
</div>
</dialog> Sizes
Dialog Sizes
<dialog class="dialog-sm">...</dialog> <!-- 24rem -->
<dialog>...</dialog> <!-- Default -->
<dialog class="dialog-lg">...</dialog> <!-- 48rem -->
<dialog class="dialog-full">...</dialog> <!-- Viewport --> Pattern
Confirmation Dialog
<dialog class="dialog-confirm" aria-labelledby="confirm-title">
<div class="dialog-body">
<h3 id="confirm-title">Delete this item?</h3>
<p class="text-secondary">This cannot be undone.</p>
</div>
<div class="dialog-footer">
<button class="btn btn-secondary">Cancel</button>
<button class="btn btn-red">Delete</button>
</div>
</dialog> Pattern
Scrollable Dialog
Advanced
Stacked Dialogs
<dialog class="dialog-layer-1">...</dialog>
<dialog class="dialog-layer-2 dialog-sm">...</dialog>
<dialog class="dialog-layer-3">...</dialog> Alerts
Standard Alerts
<div class="alert alert-blue" role="status">
<span class="alert-content">Info message here.</span>
</div>
<div class="alert alert-green" role="status">
<span class="alert-content">Success!</span>
</div>
<div class="alert alert-red" role="alert">
<span class="alert-content">Error occurred.</span>
</div> Outline
Outlined Alerts
Tinted background with a full border using alert-outline.
<div class="alert alert-blue alert-outline">
<span class="alert-content">Outlined info alert.</span>
</div> Ghost
Ghost Alerts
Transparent background with border only using alert-ghost.
Interactive
Dismissible Alerts
Add an alert-dismiss button to make alerts closeable.
<div class="alert alert-blue" role="alert">
<span class="alert-content">Dismissible alert.</span>
<button class="btn btn-ghost btn-white btn-icon btn-xs" aria-label="Dismiss">×</button>
</div> Labels
Inline Labels & Status
Outlined Labels
<span class="label label-blue">Blue</span>
<span class="label label-outline">Outline</span>
<span class="label label-outline label-red">Red Outline</span> Badges
Badges
<span class="badge badge-blue">5</span>
<span class="badge badge-red">99+</span>
<span class="badge badge-small badge-green">sm</span> Disclosure
Accordion
Collapsible content built on native <details> and
<summary> — no JavaScript. ply styles the toggle with a
right-aligned caret that rotates when open. Each item opens independently.
What is ply?
A ratio-based, AI-ready CSS framework with WCAG 2.1 AA accessibility, dark mode, and a ~5KB tree-shaken footprint.
Does it need JavaScript?
No. The accordion uses the native <details> element,
so it works with zero JavaScript and is accessible by default.
How do I theme the caret?
The caret color follows --ply-color-secondary and inherits
your theme automatically.
<details>
<summary>What is ply?</summary>
<p>A ratio-based, AI-ready CSS framework.</p>
</details>
<details open>
<summary>Does it need JavaScript?</summary>
<p>No. It uses the native <details> element.</p>
</details> Toast
Toast Messages
Fixed-position toast notifications using tools-message (alias: message).
Hidden by default — toggle display with JavaScript.
<div class="alert alert-green message" role="status" aria-live="polite">
<span class="alert-content"><strong>Saved!</strong> Changes applied.</span>
<button class="alert-dismiss" aria-label="Dismiss"></button>
</div>
<!-- For errors, use role="alert" and aria-live="assertive" -->
<div class="alert alert-red message" role="alert" aria-live="assertive">
<span class="alert-content">Error occurred.</span>
<button class="alert-dismiss" aria-label="Dismiss"></button>
</div> Accessibility
- Use
role="status"andaria-live="polite"for informational toasts — screen readers announce them after finishing the current task. - Use
role="alert"andaria-live="assertive"for errors — screen readers interrupt immediately. - Always include a dismiss button with
aria-label="Dismiss". - Toasts should auto-dismiss after a reasonable delay (5–10s), but not for error messages that require user action.
alert message | Base toast (fixed top-right) |
alert alert-blue message | Blue toast |
alert alert-red message | Red toast |
alert alert-green message | Green toast |
alert alert-yellow message | Yellow toast |
alert alert-black message | Black toast |
Reference
Alert Class Reference
All alert classes use the tools-alert-* prefix with shorter alert-* aliases.
tools-alert / alert | Base alert |
tools-alert-blue / alert-blue | Blue/info |
tools-alert-red / alert-red | Red/error |
tools-alert-green / alert-green | Green/success |
tools-alert-yellow / alert-yellow | Yellow/warning |
tools-alert-black / alert-black | Black/neutral |
tools-alert-outline / alert-outline | Outlined variant |
tools-alert-ghost / alert-ghost | Ghost variant |
tools-alert-icon / alert-icon | Icon container |
tools-alert-content / alert-content | Content wrapper |
tools-alert-dismiss / alert-dismiss | Dismiss button |
Next
Next Steps
Explore utility classes for spacing, display, and layout helpers, or learn about built-in accessibility features.