Skip to content
Studio

@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 is st-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). A className you 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 --x and --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-system dist/tokens.js. A test fails if one is written in the source.
  • SSR-safe. Nothing touches window at 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. Below overlay-at they open as bottom sheets with the same roles.

Keyboard contracts

ComponentContract
MenuOpens 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.
SelectFocus 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, TabsOne 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, SheetA 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.
DrawerA 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.
AddressFieldDomain 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, PaletteItemThe 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, DomainPickerFocus 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.
ToastProviderAt 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.
ListRowThe 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.
TooltipShows 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.
CodeEditorTab 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.
CodeBlockThe 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

ExportWhat it isKey props
ThemeProvider, useThemeLight, dark or system. Persisted, and sets data-theme on <html> (system removes it).storageKey (default studio.theme), defaultTheme; hook → { theme, resolved, setTheme }
themePreflight, applyTheme, readThemeOne inline <head> statement that applies the stored theme before first paint, plus helpers.storageKey
Density, useDensityAiry or compact; sets data-density on a wrapper or, with root, on <html>.value, root
ToolbarFloating 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, ContextPillGlass 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
ToolbarSearchSearch 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, SkipLinkThe narrow editor dock and the skip link.label; icon, label, href/onClick, current, pressed, primary
ButtonPill button: primary, secondary, ghost or danger.variant, size, icon, iconEnd, loading, extra
IconButtonA true circle, with a required name and a count badge.label, icon, variant (plain/glass), badge, pressed
CapsLink, KbdMono-caps pill link and key hint.href
Kicker, TwoToneMono-caps line with the lime dot; Bounded headline with an Instrument Serif <em> accent.dot; accent, as, size
SectionHeader, PageHeadSection head (kicker, two-tone title, link); page head (display title, lead, facts).title, accent, kicker, link/action; lead, facts, actions
Card, FeatureCardHairline card; the large create card.as, interactive; kicker, title, accent
CreateTile, TemplateCard, TemplateRailCreate tile; template card (a token-tinted placeholder, never a broken image); scrolling rail.kind, icon, title, blurb; art, tone, meta; label
StatTile, DeltaPill, SparklineMetric tile (the label truncates before it reaches the delta), signed change, trend line.label, value, sub, delta, spark, featured; value, goodWhen; values, label
AreaChartOne 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, RankListRing of shares with a legend that carries the values; ranked rows with share bars (--share).segments, center; items, scale, showShare
ListRowRecents 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, AvatarSmall display pieces. A status always shows its word.kind; status, label; selected/onChange; tone; name, src, size
Field, TextareaLabelled pill input and textarea: hint, error, mono, unit, trailing.label, hint, error, mono, unit, trailing
InputPillLarge mono input with an inline lime submit and an addon slot.label, submitLabel, onSubmit, addon, icon
DomainPickerShort-domain chooser: preset listbox plus a custom domain field.value, onChange, domains, allowCustom, customHint
SelectListbox select.label, value, options, onChange, name
Checkbox, Radio, Toggle, RangeForm value, native radio, self-saving switch, slider (--fill) with its value.checked/onChange; name, value; description; min, max, step, format
Swatch, SwatchGroupColour chip; a radiogroup of chips.color, label, value
Segmented, TabsRadiogroup segmented control; tabs with automatic activation.label, value, options, itemRole; items
Menu, MenuItem, MenuSeparator, MenuLabel, MenuGroup, useMenuMenu button and its parts.trigger, label, align, size, onOpenChange; onSelect, href, icon, shortcut, tone, checked
AccountMenuAvatar 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, TooltipAnchored non-modal panel; describing tooltip.trigger, label, title; label, shortcut
ToastProvider, useToastGlass pill toasts.toast(message, { tone, action, duration }), dismiss(id)
Modal, SheetDialog and bottom sheet.open, onClose, title, description, footer, onSubmit, size
DrawerThe 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, addressOfWhere an addressable resource lives: domain · slug · Copy, with live validation.domain, onDomainChange, domains, slug, onSlugChange, validate, hint, onSuggest, prefix, onCopy
ShareCardWhat 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, DropIndicatorDirect 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, useAnnouncerThe canvas's pure helpers and a polite live region.(list, from, to); (list, item, at); (y, rects); → { region, announce }
Panel, PanelSectionGlass 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, EmptyStateInline notice; empty list, search or canvas.tone, title, live, action; title, actions
TableData table in a focusable scroll region.caption, columns, rows
Skeleton, Spinner, ProgressLoading placeholders and progress (--value).shape, lines; label; value, max
CanvasEditor stage: dot lattice, baseline grid, zoom (--zoom).label, zoom, lattice, baseline, overlay
CodeBlockHighlighted 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
CodeEditorA 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, renderTokensThe 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.—
useShortcutsKey bindings. mod is ⌘ or Ctrl. Unmodified keys skip text fields.{ 'mod+k': fn }, { enabled, allowInFields }
useMediaThresholdtrue when the viewport, or a container, is at least a named threshold wide.name, { container, initial }
useCopyClipboard copy with a "Copied" toast and a copied flag that lasts copy-confirm.{ message } → { copy, copied }
useUndoUndo and redo history, with merged steps.initial, { limit } → { value, set, undo, redo, canUndo, canRedo }
threshold, motionMs, isSheetWidth, initials, compact, niceMax, filterCommands, normalizeHostPure 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
Contents