@aidenlive/studio-react
Studio's components for React 19: the floating glass toolbar, pill controls, menus and dialogs, the Home and Analytics data displays, and the editor frame. They are styled by @aidenlive/studio-system. Every value comes from packages/system/DESIGN.md.
import '@aidenlive/studio-system/studio.css';
import { ThemeProvider, ToastProvider, Toolbar, BrandMark, Button } from '@aidenlive/studio-react';
Peer dependencies: react and react-dom 19, @phosphor-icons/react 2.1 (the icon vocabulary), and @aidenlive/studio-system 2.0.0. The package is ESM, compiled by tsc to dist/ (.js and .d.ts). Every prop has TSDoc; your editor shows it.
Dependencies: @dnd-kit/core 6.3.1, @dnd-kit/sortable 10.0.0, @dnd-kit/modifiers 9.0.0 and @dnd-kit/utilities 3.2.2 (MIT), for the page canvas's drag and drop (CanvasDnd and its parts).
Conventions
- Classes. Each component renders
st-classes. A part isst-block__part. A modifier is a data attribute (data-variant,data-size,data-tone,data-kind,data-status,data-featured,data-sheet). State is ARIA (aria-checked,aria-selected,aria-pressed,aria-current,aria-expanded). AclassNameyou pass is added to the component's class and never replaces it. - No layout in JS. The only inline styles are custom properties that carry data:
--share,--value,--fill,--swatch,--zoom,--hue, chart positions--xand--y, and layer anchors--st-top,--st-left,--st-right,--st-bottom,--st-min-w. A test enforces this. - Numbers from tokens. Thresholds (
overlay-at,toolbar-full-at…) and timings (toast-duration,tooltip-delay,typeahead-window,copy-confirm…) come from@aidenlive/studio-systemdist/tokens.js. A test fails if one is written in the source. - SSR-safe. Nothing touches
windowat import time. Storage is read after mount, and storage that is blocked or full never throws. - Reduced motion. Exit timings drop to zero and the stylesheet stops animation.
- Layers (menus, listboxes, popovers, tooltips) are portalled to
<body>, or into the open<dialog>that holds their trigger. Belowoverlay-atthey open as bottom sheets with the same roles.
Keyboard contracts
| Component | Contract |
|---|---|
Menu | Opens on the first item (↑ on the trigger opens on the last). ↑ ↓ move and wrap. Home and End jump. A letter jumps to the next item that starts with it. Esc closes and returns focus to the trigger. Tab closes and moves on from the trigger. A press outside closes it. Items are roving: the menu is one Tab stop. |
Select | Focus stays on the trigger (role="combobox", aria-activedescendant). Space, Enter, ↓ and ↑ open. Arrows skip disabled options. Typing jumps within typeahead-window. Enter commits, Esc keeps the old value, Tab commits. |
Segmented, SwatchGroup, Tabs | One Tab stop. Arrows move and select, and wrap. Home and End jump. Inside a menu, Segmented with itemRole="menuitemradio" takes ← and →, and ↑ ↓ stay with the menu. |
Modal, Sheet | A native <dialog>. It focuses the data-autofocus element, else the first field (caret at the end, nothing selected), else the dialog (never the close button). Tab and Shift+Tab stay inside. Esc, the close button and a backdrop press call onClose. On close, focus returns to the opener. |
Drawer | A modal <dialog> from the end edge (a full-height sheet below shell-rail-at). Focus moves to the name (an existing resource) or, with focusRequired (a new one), the first empty required field; the caret goes to the end and nothing is selected; Tab stays inside; the page behind does not scroll. Esc, the close circle and the backdrop close, and with dirty set they first ask "Discard unsaved changes?" (Keep editing is focused; Esc there keeps editing). In the name, Enter commits and Esc restores it. On close, focus returns to the opener. |
AddressField | Domain picker, slug and Copy in one rim; the slug's accessible description is the full URL. The rule shows under it until the slug has a problem; validate runs on every change and shows once the slug is edited or left. |
CanvasDnd, CanvasBlock, PaletteItem | The selected block is the canvas's one Tab stop (the first block when nothing is selected); focusing a block selects it. A palette item is a button: Enter or a press adds its block; a mouse, pen or touch drag (touch after a short press) drops it where the drop indicator shows. A block's handle drags it, and is a button too: Space lifts, ↑ ↓ move, Space drops, Esc cancels. The app wires Alt/Option + ↑ ↓ on the block with moveItem. Every move is announced politely. |
Popover, DomainPicker | Focus moves into the panel. Esc and a press outside close it and return focus. In the domain list, ↑ ↓ move and Enter or Space picks. |
ToolbarSearch | ⌘K (Ctrl+K off Apple platforms) or a press opens the command layer. Typing filters. ↑ ↓ move while focus stays in the input. Enter runs the command. Esc returns focus. |
ToastProvider | At most three toasts. Each stays toast-duration, or toast-action-duration when it has an action. The timer pauses while the toast is hovered or focused. Errors go to role="alert", the rest to role="status". The action runs, then the toast closes. |
ListRow | The title is the row's link, stretched over the row, so the row is one Tab stop. The overflow menu sits above the link and opens without following it. |
Tooltip | Shows after tooltip-delay on hover with a fine pointer, and at once on keyboard focus. Esc hides it. It describes the element; it never names it. |
CodeEditor | Tab indents (every selected line when the selection spans lines) and Shift+Tab outdents. Esc then Tab (or Shift+Tab) leaves, so it is never a trap; the hint under the field says so. The first Esc stays in the editor, a second reaches the surface around it (a drawer closes). Read-only and disabled editors never take Tab. Edits go through the browser's insertText, so undo works. |
CodeBlock | The code region is one Tab stop (it scrolls). The copy button copies the code without line numbers and confirms with a toast and its name ("Copied"). |
API
| Export | What it is | Key props |
|---|---|---|
ThemeProvider, useTheme | Light, dark or system. Persisted, and sets data-theme on <html> (system removes it). | storageKey (default studio.theme), defaultTheme; hook → { theme, resolved, setTheme } |
themePreflight, applyTheme, readTheme | One inline <head> statement that applies the stored theme before first paint, plus helpers. | storageKey |
Density, useDensity | Airy or compact; sets data-density on a wrapper or, with root, on <html>. | value, root |
Toolbar | Floating glass chrome: start, centre, primary, secondary actions, end. Below compose-at (CSS) the secondary actions, and a ToolbarSearch or AccountMenu in end, fold into "More" (as Search and Account); the primary keeps one word. useToolbarOverflow lets your own end item fold the same way. | label, start, center, primary, actions (disabled, overflowOnly), end |
ToolbarPill, BrandMark, ContextPill | Glass pill, brand circle, and the context pill (label, document name with a menu, status dot, save state as icon and word in a polite live region). | label; href, name; docName, menu, status, saveState |
ToolbarSearch | Search field plus the ⌘K command layer. In a toolbar's end it is a glass circle. | commands, placeholder, shortcut, open/onOpenChange, triggerLabel, overflowLabel |
Dock, DockItem, SkipLink | The narrow editor dock and the skip link. | label; icon, label, href/onClick, current, pressed, primary |
Button | Pill button: primary, secondary, ghost or danger. | variant, size, icon, iconEnd, loading, extra |
IconButton | A true circle, with a required name and a count badge. | label, icon, variant (plain/glass), badge, pressed |
CapsLink, Kbd | Mono-caps pill link and key hint. | href |
Kicker, TwoTone | Mono-caps line with the lime dot; Bounded headline with an Instrument Serif <em> accent. | dot; accent, as, size |
SectionHeader, PageHead | Section head (kicker, two-tone title, link); page head (display title, lead, facts). | title, accent, kicker, link/action; lead, facts, actions |
Card, FeatureCard | Hairline card; the large create card. | as, interactive; kicker, title, accent |
CreateTile, TemplateCard, TemplateRail | Create tile; template card (a token-tinted placeholder, never a broken image); scrolling rail. | kind, icon, title, blurb; art, tone, meta; label |
StatTile, DeltaPill, Sparkline | Metric tile (the label truncates before it reaches the delta), signed change, trend line. | label, value, sub, delta, spark, featured; value, goodWhen; values, label |
AreaChart | One or two series in token-driven SVG. HTML axes, a hover and arrow-key readout, and a hidden data table. | label, series, labels, xTicks, yTicks, formatAxis, formatValue |
Donut, RankList | Ring of shares with a legend that carries the values; ranked rows with share bars (--share). | segments, center; items, scale, showShare |
ListRow | Recents row: thumb, title link, kind badge, meta, value, overflow menu. | title, href, onOpen, kind, thumb, host, status, value, unit, menu |
KindBadge, StatusDot, Chip, PlanChip, Badge, Avatar | Small display pieces. A status always shows its word. | kind; status, label; selected/onChange; tone; name, src, size |
Field, Textarea | Labelled pill input and textarea: hint, error, mono, unit, trailing. | label, hint, error, mono, unit, trailing |
InputPill | Large mono input with an inline lime submit and an addon slot. | label, submitLabel, onSubmit, addon, icon |
DomainPicker | Short-domain chooser: preset listbox plus a custom domain field. | value, onChange, domains, allowCustom, customHint |
Select | Listbox select. | label, value, options, onChange, name |
Checkbox, Radio, Toggle, Range | Form value, native radio, self-saving switch, slider (--fill) with its value. | checked/onChange; name, value; description; min, max, step, format |
Swatch, SwatchGroup | Colour chip; a radiogroup of chips. | color, label, value |
Segmented, Tabs | Radiogroup segmented control; tabs with automatic activation. | label, value, options, itemRole; items |
Menu, MenuItem, MenuSeparator, MenuLabel, MenuGroup, useMenu | Menu button and its parts. | trigger, label, align, size, onOpenChange; onSelect, href, icon, shortcut, tone, checked |
AccountMenu | Avatar button. The menu shows the avatar, name, mono email, plan chip, the theme choice, your items, and Sign out in danger. | name, email, plan, onSignOut, theme/onThemeChange (default: the provider), overflowLabel, className |
Popover, Tooltip | Anchored non-modal panel; describing tooltip. | trigger, label, title; label, shortcut |
ToastProvider, useToast | Glass pill toasts. | toast(message, { tone, action, duration }), dismiss(id) |
Modal, Sheet | Dialog and bottom sheet. | open, onClose, title, description, footer, onSubmit, size |
Drawer | The singular editor: head (the name, renamable in place, the Active switch, close), the address under it, the preview beside the form (size="wide") or on top, one status and the actions in the foot; the unsaved-changes guard. | open, onClose, label, title, onRename, focusRequired, active/onActiveChange, address, preview, footer, status, onSubmit, dirty, guard, size |
AddressField, addressOf | Where an addressable resource lives: domain · slug · Copy, with live validation. | domain, onDomainChange, domains, slug, onSlugChange, validate, hint, onSuggest, prefix, onCopy |
ShareCard | What is shared: a link's short URL, destination host, QR thumbnail and PNG · SVG; a vCard's contact card and .vcf. | address, destination, qr, onDownloadPng, onDownloadSvg, contact, onDownloadVcf, pending |
CanvasDnd, PaletteItem, CanvasDropZone, CanvasBlock, DropIndicator | Direct manipulation on a page canvas (@dnd-kit): drag from the palette (drop indicator), drag a block's handle, the selected block's toolbar (handle · duplicate · delete · more). | ids, onInsert, onMove, describe; type, label, onActivate; hasBlocks, empty; id, selected, tabStop, onDuplicate, onDelete, more, onKeyDown; index |
moveItem, insertItem, dropIndexAt, useAnnouncer | The canvas's pure helpers and a polite live region. | (list, from, to); (list, item, at); (y, rects); → { region, announce } |
Panel, PanelSection | Glass library or inspector, and its sections. With className="st-editor__panel" and open, the panel is the editor's panel itself. | title, actions, side, open, data-*; label, action |
Callout, EmptyState | Inline notice; empty list, search or canvas. | tone, title, live, action; title, actions |
Table | Data table in a focusable scroll region. | caption, columns, rows |
Skeleton, Spinner, Progress | Loading placeholders and progress (--value). | shape, lines; label; value, max |
Canvas | Editor stage: dot lattice, baseline grid, zoom (--zoom). | label, zoom, lattice, baseline, overlay |
CodeBlock | Highlighted code from Studio's Prism fork, built as React nodes (never HTML from the code); SSR-safe. Caption, language, a line gutter, highlighted and diff lines, a copy button. | code, language, lineNumbers, highlightLines, addedLines, removedLines, caption, copy, copyLabel, label |
CodeEditor | A transparent textarea over the highlighted paint, with a line gutter; label, hint and error as Field has them. | label, value, onChange, language, readOnly, disabled, error, hint, hideLabel, lineNumbers, indent, exitHint |
highlight, highlightHtml, splitLines, resolveLanguage, renderTokens | The highlighter (@aidenlive/studio-system/highlight): highlight(code, lang) → [{ text, role }], lines-safe; roles are code-roles.json; markup, css, js, ts, jsx, tsx, json, bash, swift, yaml, markdown, go, with aliases (html, sh, ts, yml, …); unknown is plain. | — |
useShortcuts | Key bindings. mod is ⌘ or Ctrl. Unmodified keys skip text fields. | { 'mod+k': fn }, { enabled, allowInFields } |
useMediaThreshold | true when the viewport, or a container, is at least a named threshold wide. | name, { container, initial } |
useCopy | Clipboard copy with a "Copied" toast and a copied flag that lasts copy-confirm. | { message } → { copy, copied } |
useUndo | Undo and redo history, with merged steps. | initial, { limit } → { value, set, undo, redo, canUndo, canRedo } |
threshold, motionMs, isSheetWidth, initials, compact, niceMax, filterCommands, normalizeHost | Pure helpers. | — |
Checks
npm run build -w @aidenlive/studio-react # tsc → dist/
npm run typecheck -w @aidenlive/studio-react # tsc --noEmit (strict)
npm run check -w @aidenlive/studio-react # dist/ is current with src/
npm test -w @aidenlive/studio-react # node --test: ssr.test.mjs (no DOM), keyboard.test.mjs (jsdom)
npm run classes -w @aidenlive/studio-react # every st- class rendered exists in components.css