UI root
A React component in Beamline's Layout category, in the free sample.
Makes a region of any app a Beamline root: theme, brand and direction for everything inside, and a matching layer at page level where its menus, dialogs and tooltips open.
Use it for
- Using Beamline inside an app that has its own styles: wrap only the screens or widgets that use the system, so nothing outside the root is affected.
- A region with a different theme, brand or direction from the rest of the page (a dark trading panel in a light app).
Not for
- An app built entirely on the system: put class="pui dark" on <html> instead (no wrapper, overlays open in the page).
- Right-to-left text alone inside an existing root (direction).
Anatomy
- root (div.pui with the theme class, data-theme, data-accent, dir, and --pui-brand when set)
- portal layer (div.pui appended to <body>, mirroring theme, accent, brand and dir; every overlay inside the root renders into it)
Variants
- theme: dark, light
- dir: ltr, rtl
- accent: blue, violet, green, amber, orange, rose, neutral
States
- server and first client render: managed portal pending
- attached: stable portal destination
- appearance changed: same controls and portal node
- inherit=false resets numeric foundation parameters on both root and stable portal
- per-host CSS timing overrides are resolved independently of sibling regions
- locale/message updates preserve mounted controls and open portal state
- nested roots inherit locale and message keys; inherit=false resets them
Keyboard
- None of its own; sets the direction Radix parts use for ←/→ inside rtl.
Motion
None. Changing theme switches tokens in one frame.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
theme | "dark" | "light" | "system" | "dark" | dark, light, or "system": the device's setting, followed as it changes. Rendered on the server, "system" writes no theme (the page's, set before paint by ThemeScript, shows through) and takes the device's once in the browser. |
brand | string | — | Any CSS colour; becomes --pui-brand. Accent, focus ring, series 1 and glows derive from it (Prism keeps its spectrum for charts and takes the brand for its main action, focus ring and glows). |
accent | "blue" | "violet" | "green" | "amber" | "orange" | "rose" | "neutral" | — | An accent preset. None: the look's own default brand (Prism's white light, Pop's tomato, else blue). |
dir | "ltr" | "rtl" | "ltr" | Reading direction for the region and its overlays. |
look | "soft" | "blueprint" | "glass" | "metal" | "glow" | "pop" | "mono" | "ink" | "soft" | Deprecated: Import selected preset CSS and pass its pure reference through preset. |
motionScale | number | — | Animation speed: multiplies every duration and spring (CSS and JS). 1 = foundation default. |
radiusScale | number | — | Roundness: scales the style's radii (pinned identity radii excepted). 0 = square. |
typeScale | number | — | Type size: multiplies every step of the type scale. |
typeRatio | number | — | Type contrast: exponent on each step's distance from body size; <1 flatter, >1 more dramatic. |
spaceScale | number | — | Spacing: scales the 4px spacing tokens and named paddings/gaps (not control heights or row density). |
preset | PresetRef | — | A built-in look or a custom preset { id, visualContract: 1, base } whose stylesheet the app imports. |
density | "compact" | "default" | "comfortable" | — | Row density for tables, grids and order books in this scope and its overlays. |
motion | "auto" | "reduced" | "none" | — | Motion mode; auto follows the OS. |
className | string | — | Classes on the documented visual root; no override by default. |
children (required) | ReactNode | — | |
locale | string | — | BCP 47 language; inherits from the nearest root, then the document, then en-US. |
messages | Messages | — | Sparse, namespaced overrides for all built-in copy. Instance labels win. |
pseudoLocale | boolean | false | Accent and expand built-in English for layout and untranslated-copy checks. |
ThemeScript / themeScript / themeScriptHash | component / (options) => string / (options) => Promise<string> | — | The theme set on <html class="pui"> before the first paint, from a stored choice (storageKey) or the device: no flash on a server-rendered page. CSP-safe: pass the request's nonce to <ThemeScript nonce>, or allow it by themeScriptHash() in script-src. Server-safe import: @beamline/runtime/theme-script. |
inherit | boolean | — | False resets managed ancestor choices before applying local inputs. |
defaults | Readonly<Record<string, Readonly<Partial<Record<DesignDefaultKey, DesignDefaultValue>>>>> | — | |
ref | Ref<HTMLDivElement> | — | Receives the documented native target or imperative handle; omitted by default. |
tokens | AppearanceTokens | — | |
appearanceClassName | string | — | |
displayScale | number | — | Hero size: scales the one headline a screen leads with (.text-display), after type size and contrast. |
Built from
- Every overlay (dialog, sheet, popover, menus, select, tooltip, hover card, toast) reads usePortalContainer() from here.
Dependencies
@radix-ui/react-direction
Import
import { UIRoot, ThemeScript } from "@beamline/runtime";
Get it
UI root is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. UI root is included in the free MIT sample. Get Beamline · Connect your agent
More in Layout
- Bezel: A double-bezel frame: an outer shell with a hairline, a small gap, and an inset panel with its own edge, so a preview, chart or media reads as set into…
- Carousel: A row of slides that snap into place: swipe on touch, drag or the arrows with a mouse, ← → when focused, or the dots; optional autoplay that pauses and…
- Card: A record or a small group of related content and actions: optional media, avatar, title, status, action, meta, free content and a Details toggle; plain…
- Resizable panels: Panes that trade space across draggable dividers; each divider is a focusable separator with arrow keys, limits, folding for collapsible panes and…
- Expandable card: A dense card that grows in place when asked: the frame resizes and the clamped preview opens into the full text.
- Accordion: Topics that open in place, one at a time or several: FAQs and settings sections; each header is a button (with an optional fact at its end), and the…
- Collapsible: One region that opens and closes in place from its trigger, its height animating to the content.
- Scroll area: A native scroll region with thin overlay thumbs and edge fades that show only where more content waits; thumbs can be dragged or clicked.
- Aspect ratio: Holds media, video and embeds at a fixed width-to-height ratio while the layout resizes.
- Direction: Sets left-to-right or right-to-left for everything inside: text and logical spacing flip, and Radix parts read the direction for keys and placement.
- Separator: A hairline between groups, horizontal or vertical; hidden from screen readers unless it carries meaning.