@stnd/ui
Shared UI components for the Standard Ecosystem.
Most buttons/badges/cards should just be a CSS class on plain HTML (see @stnd/styles) — no JS, no import. This package is only for the handful of things that genuinely need interactivity: a dropdown that manages keyboard navigation, a confirm dialog you can await, a right-click menu. If you’re reaching for a component here and it’s not doing something stateful or ARIA-heavy, check whether a CSS class already does the job.
Use it (the confirm dialog, the most common one):
import { confirm } from "@stnd/ui/dialog.js";
const ok = await confirm({ title: "Delete this?", intent: "danger" });
Overview
@stnd/ui provides a collection of reusable, accessible, and high-quality UI components built for Astro and Svelte 5. These components are designed to work seamlessly with @stnd/styles and follow the Standard design principles.
🏛 The Philosophy: CSS First, Components Second
Standard is built on the philosophy of keeping the codebase as clean, fast, and static as possible. Before importing a component from @stnd/ui, ask yourself: Can this be done with just HTML and @stnd/styles?
Many UI elements you see in the Playground (like Buttons, Badges, Cards, and Inputs) are not components. They are simple CSS classes applied to standard HTML elements.
Why?
- Zero JavaScript overhead.
- Perfect semantic HTML.
- Maximum flexibility without passing dozens of props.
Example: Buttons & Badges (CSS Only)
You do not need a <Button> or <Badge> component. Just use the global classes provided by @stnd/styles:
<!-- Primary Button -->
<button class="btn">Save Changes</button>
<!-- Ghost Button -->
<button class="btn ghost">Cancel</button>
<!-- Success Badge -->
<span class="badge success">Active</span>
When to use @stnd/ui Components?
You should only import components from this package when you need:
- Complex interactivity (e.g.,
Dropdown,ContextMenu). - State management (e.g.,
DialogManager,ComboBox). - Advanced Accessibility / ARIA management (e.g.,
Accordion). - Complex composition (e.g.,
Accordion,Scroller,TableOfContents).
Icons and Lottie animations are not in this package — they live in
@stnd/icon(import Icon from "@stnd/icon/Icon.astro"). See its README.
🧩 Component API Reference
Design System Playground
Every @stnd/ui component and design token in one place. A living quality check — flip themes in the Lab and watch everything update.
Accordion
Is it accessible?
Yes. It adheres to the WAI-ARIA design pattern.
Is it styled?
Yes. It comes with default styles that matches the other components' aesthetic.
Is it animated?
Yes. It's animated by default, but you can disable it if you prefer.
Avatar
Badge
Card
Login to your account
Enter your details below to login to your account
Meeting Notes
Transcript from the meeting with the client.
Client requested dashboard redesign with focus on mobile responsiveness.
- New analytics widgets for daily/weekly metrics
- Simplified navigation menu
- Dark mode support
- Timeline: 6 weeks
- Follow-up meeting scheduled for next Tuesday
Is this an image?
This is a card with an image.
Header and Content
This is a card with a header and a content.
Header + Content + Footer
This is a card with a header, content and footer.
Skeleton
Table
| Invoice | Status | Method | Amount |
|---|---|---|---|
| INV001 | Paid | Credit Card | $250.00 |
| INV002 | Pending | PayPal | $150.00 |
| INV003 | Unpaid | Bank Transfer | $350.00 |
| INV004 | Paid | Paypal | $450.00 |
| INV005 | Paid | Credit Card | $550.00 |
| INV006 | Pending | Bank Transfer | $200.00 |
| INV007 | Unpaid | Credit Card | $300.00 |
| Total | $2,500.00 | ||
Tooltip
Toast
Lightweight notification system. Dispatches a custom toast event — no framework needed. The Toast component listens globally and renders items in a fixed container at the top of the viewport.
Scroller
A fixed scroll-progress bar at the very top of the page. It's already active on this page — scroll down and watch the thin line fill. No configuration needed; it's mounted automatically by the Base layout.
The bar at the top of this page is the Scroller. It uses window.scrollY and the document height to compute a 0–100% fill width, rendered as a glassmorphic strip with a glow shadow.
Example: 60% through page
Button
Checkbox
By clicking this checkbox, you agree to the terms and conditions.
Form
Input
Label
Radio Group
Slider
Switch
Textarea
Type your message and press enter to send.
Dialog
Dialog Manager
Programmatic confirmation dialogs via a Svelte store. Call confirm({ title, description }) from any script — it returns a Promise<boolean>. Mount DialogManager once in the layout; it handles rendering.
Popover
Dimensions
Set the dimensions for the layer.
Select
Combobox
Context Menu
Right-click (or long-press) the cards below. The menu is viewport-aware — try near screen edges.
Hue Palette
Every hue derived from the foreground seed via OKLCH offsets.
redorangeyellowgreencyanbluemagentaSemantic Colors
Status, feedback, and UI signal colors.
successwarningerrorinfoaccentlinkForeground Tones
--color-foreground--color-muted--color-subtle--color-border--color-backgroundSurface Elevations
--color-surface-lower--color-surface-lowest--color-surface-low--color-surface--color-surface-high--color-surface-highest--color-surface-higherColored Text
Each hue as body text on the page background. Verify every color remains legible at reading size.
The quick red fox. 0123456789
The quick orange fox. 0123456789
The quick yellow fox. 0123456789
The quick green fox. 0123456789
The quick cyan fox. 0123456789
The quick blue fox. 0123456789
The quick magenta fox. 0123456789
The quick success fox. 0123456789
The quick warning fox. 0123456789
The quick error fox. 0123456789
The quick info fox. 0123456789
The quick accent fox. 0123456789
The quick link fox. 0123456789
Button Palette
All variants and every palette hue. Flip themes in the Lab to verify contrast.
Badge Palette
Filled, secondary, and outline variants across all hues.
Alert Palette
Semantic alert banners. Border, background tint, and text must all remain readable.
Real-World Patterns
Typical UI patterns combining color with text and backgrounds.
Type Scale
6xlAg5xlAg4xlAg3xlAg2xlAgxlAglgAgbaseAgsmAgxsAg2xsAg3xsAgSans
Inter — rmts
Everyone has the right to freedom of thought, conscience and religion; this right includes freedom to change his religion or belief.
Serif
Source Serif 4
No one shall be subjected to arbitrary arrest, detention or exile. Everyone is entitled in full equality to a fair and public hearing.
Monospace
IBM Plex Mono
No one shall be held in slavery or servitude; slavery and the slave trade shall be prohibited in all their forms.
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Spacing Tokens
All spacing is based on --baseline (1rlh).
--space-d8--space-d6--trim--space-d4--leading--space-d3--space-d2--space-half--space--space-2--space-3--space-4--space-6--space-8--space-12Content Measure
Max content widths for readability.
--line-width-xs--line-width-sm--line-width-md--line-width-lg--line-width-xlShadows
Raised
--shadow-raisedDefault surfaceAmbient
--shadowSubtle drop shadowLarge
--shadow-lgAmbient + liftExtra Large
--shadow-xlAmbient + lift + glowGlow
--shadow-glowAccent-colored glowInset
--shadow-insetPressed stateRing
--shadow-ring1px inset borderEasing & Speed Lab
Visualize and compare the transition timing functions and durations available in the framework. Pick a preset or define a customcubic-bezier, adjust the duration, then hit Play.
transition: all 0.5s ease;Compare two easings side-by-side
Astro Components (Zero JS)
<Accordion />
Accessible, collapsible content sections.
open(boolean): Sets the initial open state.
Svelte 5 Components (Hydrated)
<Alert />
Semantic feedback banners.
class(string): The semantic intent:success,warning,error,info. (Defaults to accent color).title(string): Optional bold title.icon(string): Optional string icon (e.g.,✓,⚠).
<Alert class="warning" title="Watch out!" icon="⚠">
This action cannot be undone.
</Alert>
<Dropdown />
Accessible, keyboard-navigable dropdown menus.
align(string): Alignment of the menu (start,end). Defaults tostart.label(string): Recommended accessible name for the native trigger button. When supplied, thetriggersnippet contains only its content (not another button).triggerClassstyles that button;openis bindable. Existing trigger snippets withoutlabelremain supported.- Slots:
trigger(the button that opens the menu),default(the menu items). - Arrow keys and Home/End move among enabled items; Escape dismisses and restores trigger focus. Item activation closes the menu; Tab dismisses and continues focus navigation. Native button keyboard activation does not toggle twice.
Related Sub-components:
<DropdownItem icon="ph:user" shortcut="⌘P">Profile</DropdownItem><DropdownLabel label="My Account" /><DropdownSeparator />
<ContextMenu />
Viewport-aware right-click menus.
- Slots:
default(the area that triggers the menu on right-click),content(the menu items). - For delegated/virtualized targets, omit the default snippet and pass
open,position={{ x, y }}(viewport coordinates),label, andonclose.openis bindable. The shared menu measures its actual content, clamps to the viewport, and scrolls oversized menus. - Arrow keys and Home/End move among enabled items. Escape, Tab, outside clicks, viewport resize, and scrolling outside the menu dismiss it. Focus returns to the previous element when appropriate. Context-menu item components use native disabled state as well as ARIA.
<Dialog />
A general-purpose native modal shell for forms and other arbitrary content. This complements AlertDialog/confirm(); it does not add confirmation semantics.
<Dialog bind:open label="Preferences" onclose={discardDraft}
style="--dialog-width: 580px; --dialog-max-height: 88vh">
<!-- Form content and semantic buttons belong to the consumer. -->
</Dialog>
label is the accessible name; children supplies content; class and style customize the shell. onkeydown can implement a content-specific shortcut. The component owns showModal(), background inertness, native focus behavior, Escape/backdrop dismissal, and focus restoration. It stops keyboard propagation to application shortcut handlers. Use it for modal interactions, not for live nonmodal monitors or native OS windows.
<Popover />
An anchored, nonmodal popup for forms and mixed controls. Use Dropdown for menus of actions instead.
<Popover label="Display options" align="end">
{#snippet trigger(attributes)}
<button class="btn ghost" {...attributes}>Display</button>
{/snippet}
<!-- Native inputs and content-specific buttons. -->
</Popover>
Spread the trigger attributes onto a single native button; they supply its click behavior and ARIA relationship. Props: bindable open, required label, trigger and children snippets, align (start/end), side (bottom/top), optional wrapper class, and onclose. Escape restores trigger focus; outside click or focus leaving the popup/trigger dismisses it. Keyboard events inside the content do not reach application-wide shortcuts.
The shared menu geometry/navigation helpers have dependency-free tests: node --test packages/ui/menu.test.js from the repository root. Reveal’s browser UI regression suite also exercises controlled and wrapped context menus, dropdowns, popovers, and native dialogs with synthetic data; see Reveal UI validation.
🚨 Dialog Manager
The DialogManager allows you to trigger accessible confirmation dialogs programmatically from any script using a simple Promise-based API. This prevents littering your DOM with hidden modal HTML.
AlertDialog can also be composed directly inside an existing Dialog when confirmation belongs to that form. Its title provides the accessible dialog name, keyboard events stay within the confirmation instead of reaching parent form shortcuts, and a programmatic close after confirmation does not also call the cancellation callback.
1. Mount the Manager
Ensure <DialogManagerComponent client:load /> is mounted once in your root layout (Standard does this by default).
2. Call the API
import { confirm } from "@stnd/ui/dialog.js";
const isConfirmed = await confirm({
title: "Delete this item?",
description: "This action cannot be undone. Are you sure?",
confirmLabel: "Yes, Delete",
cancelLabel: "Cancel",
intent: "danger" // "neutral" | "danger"
});
if (isConfirmed) {
// Proceed with deletion
}
Notes / Observations
(jot down anything noticed here — quirks, gotchas, ideas)
Todo
- README is thin relative to the component count —
Combobox, priority: 3 token_scale: 3 created: 2026-07-14 area: framework
Panel,Pagination,Scroller,TableOfContents,Toast,CfImage,LauncherHintexist on disk but aren’t documented above. Worth a pass once this package settles.
