Repository navigation
rx.ui: compiled component package and JS shell fixes - #8037
FarhanAliRaza wants to merge 250 commits into
Conversation
Plugin.get_vite_plugins() returns VitePluginEntry objects, each carrying the import statements and the expression to place in the plugins array of the generated vite.config.js, ahead of reactRouter(). Entries keep rxconfig plugin order then entry order, shared imports render once, and a malformed entry raises InvalidVitePluginError naming the plugin. With no entries the rendered file is unchanged. Claude-Session: https://claude.ai/code/session_014AwvTNGETBu7Fzvwjqecm4
An installable, empty package: `pip install 'reflex[ui]'` adds reflex-components-ui, which `rx.ui` resolves on first use. reflex does not depend on it, and without the extra `rx.ui` raises an error that names the extra. The package embeds its javascript, js/src, in the wheel, and reads it in place in a checkout. js/ carries its own tooling: ESLint with the StyleX rules and rules against components and barrel files in js/src, a type check from JSDoc, vitest, and a driver that writes generated files and fails CI when a committed one drifts. Each lint rule has a test that feeds it a file it must reject. Claude-Session: https://claude.ai/code/session_014AwvTNjM7Q5Te2EY2FTHrZ
[High impact] The PR changes page loading and generated JavaScript across Reflex apps, alongside an opt-in component package. The PR is not ready to merge: earlier compilation failures, dropped control props, and migration failures remain outstanding. Findings
SummaryAdds the compiled Since the previous review:
FarhanAliRaza documents that a whole-style Reviews (44) · Last reviewed commit: "Fix CI of rx.ui on UI SDK: imports besid..." · Reviewed by Greptile |
root.jsx imported the whole namespace of every library registered for dynamic components, which kept all of Radix Themes in the chunks every page loads. frontend_lazy_bundled_libraries now defaults to True, and the lazy path is fixed so it actually splits: - Each optional library is loaded through a generated module under utils/dynamic_libraries/. Importing the library itself from root.jsx made the bundler fold the namespace back into a statically loaded chunk whenever a page also imported from it. - Libraries the compiler registered are only made loadable when a page renders a dynamic component (one evaluated by evalReactComponent). Libraries the app registered with bundle_library always are. A production build of the blank template goes from 239.8 kB to 170.8 kB of gzipped JS. Claude-Session: https://claude.ai/code/session_014AwvTL12cX7g6Zn6HEiwG1
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
| assert ( | ||
| ' "d3-format": () => import("$/utils/dynamic_libraries/d3_format")' | ||
| ".then((module) => module.default)," | ||
| ) in code.splitlines() |
There was a problem hiding this comment.
These new assertions check whether one loader line appears in the generated file. CLAUDE.md requires tests of generated code to compare the complete output, not fragments. These checks can pass when other loaders are missing or extra imports appear.
Compare the full expected output, as test_compile_app_root_loads_optional_libraries_on_demand already does. Apply this to the other new loader assertions too, including those in test_dynamic_components_codegen.py. This repository requirement must be met before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| def test_rewrite_component_import(module: str, is_reflex_package: bool, expected: str): | ||
| assert _rewrite_component_import(module, is_reflex_package) == expected |
There was a problem hiding this comment.
New tests lack required docstrings
This new test starts directly with an assertion, but CLAUDE.md requires Google-style docstrings on all functions, including argument descriptions where needed. Add them here and to the other new tests missing them, including those in test_init.py and test_js_package.py. This repository requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
A prerendered page is visible without javascript, but react-router's <Scripts> preloads every route module from the head, where the downloads compete with the stylesheet the page needs to paint. The document's Scripts component now renders $/utils/scripts, which wraps react-router's. On a prerendered page it leaves the module preloads out of the document and replaces the module script with an inline one that adds both back on the first paint. A user input, a hidden tab, a browser without paint timing or a one second timeout start them as well. Dev mode and the SPA fallback render what react-router renders. The last click that comes before the page can handle one is dispatched again after hydration, unless the browser already acted on it. Claude-Session: https://claude.ai/code/session_014AwvTNacWVsm7SEvVjhfGM
An app without state bundled Socket.io, the cookie library and the code that connects to the backend, and every app bundled the toaster whether or not it ever showed a toast. State runtime. The connection to the backend (socket, session, browser storage sync, the event loop over the socket) moves out of utils/state.js into utils/socket.js. Only the compiled context module of an app with state imports it; it registers itself with utils/state.js through a registry in the new utils/event_loop.js, which also holds the event queue the two share. utils/state.js keeps every export it had: the ones that need the connection delegate to it, and useEventLoop runs the events the browser handles by itself (scripts, redirects, refs, storage, downloads) when there is none. _remove_cookie writes the expired cookie itself, so it needs no cookie library. Toaster. The app's default toaster is bundled when the app sends a toast: a toast call compiled into a page or an app wrap carries a ToasterRequest app wrap in its var data, an on_load toast is read from the event, and the functions of the state tree are read for references to rx.toast (by name, through helpers in the app's own modules). A toaster passed to rx.App is always bundled. Since code that runs on the backend cannot be ruled out by reading names, an app with state that gets no toaster gets a plain-DOM stand-in for the toast function instead, so a toast sent anyway and a connection error still show. The connection toaster no longer asks for the toaster by itself. Total gzipped client JS of a production build, rx.el only, no Radix or Tailwind plugin: 158.7 kB to 130.8 kB without state, 161.6 kB to 153.9 kB with state and no toast. Claude-Session: https://claude.ai/code/session_014AwvTNmJCFr12bYVhV8efZ
UIPlugin wires StyleX into the app's Vite build: the compiler and its plugin as development dependencies, the javascript package copied to .web/reflex-ui, and base.css imported first by the root stylesheet to declare the cascade layer order. UIComponent renders a plain element. Its style is emitted as a stylex.create declaration into whichever module renders the element, and spread with stylex.props, which StyleX folds to a class name string. A component held in state falls back to an inline style. The Vite wrapper fixes the React Router build (the renamed stylesheet), names the chunk that links the stylesheet after the compiled styles so a changed style never alters a file under an unchanged name, and loads the StyleX development module from the client entry. Claude-Session: https://claude.ai/code/session_014AwvTPBw2eYQiwgtLmDkpC
Recording stopped when the scripts module was imported, which left the time until hydrateRoot with no one handling a click. The entry points now take the click over immediately before they hydrate. Claude-Session: https://claude.ai/code/session_014AwvTNacWVsm7SEvVjhfGM
StyleProps is generated from the type definitions of the pinned StyleX package, so a type checker catches a misspelt CSS property or keyword. lower() turns a style into the style object StyleX compiles: conditions per property, media queries for responsive values, color scales with the module each needs, and shorthands split into longhands. merge() resolves a component's style table against the props and the style of one element, by property with the last one winning, and returns the alternatives of a prop bound to state without resolving them. StyleX silently drops the border and background shorthands, so both are always split, and animation is refused with what to set instead. Claude-Session: https://claude.ai/code/session_014AwvTMtxnRhQBAehyWjUwF
…erging Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v # Conflicts: # packages/reflex-components-ui/README.md # packages/reflex-components-ui/src/reflex_components_ui/style/__init__.py
| for combo in product(*[domains[member] for member in group]): | ||
| change = _difference( | ||
| static, merged_with(dict(zip(group, combo, strict=True))) | ||
| ) | ||
| if change: | ||
| values[combo] = finish(change, unset=True) |
There was a problem hiding this comment.
Grouped variants lose valid styles
_merge_dynamic only builds combinations from values explicitly listed in the table. When two state-bound props share a compound style, a valid value of one prop is lost if the other has an unlisted value. For example, a tone="red" variant combined with a loading="true" compound style produces no alternative for tone="red", loading=False. The static style excludes both bound props, so callers cannot recover the red variant. Include a no-match fallback for each grouped prop.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Every custom property Radix Themes defines becomes a StyleX variable with the same name and value, generated from the token stylesheet of the version the Radix components install. A color is one light-dark() value with a display-P3 variant, so an appearance is the color-scheme of an element; accent, gray, radius, scaling and panel are createTheme classes, one module per accent and per gray so an app carries only what it imports. A sweep in headless Chromium compares every custom property under these modules with @radix-ui/themes and its Theme component: part of it in npm test, the whole product of the theme props in npm run sweep. Claude-Session: https://claude.ai/code/session_014AwvTMTA184ecs3JHWuggN
…n used Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v # Conflicts: # pyi_hashes.json
…leX modules Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v # Conflicts: # packages/reflex-components-ui/README.md # packages/reflex-components-ui/js/scripts/generate.js # tests/units/reflex_components_ui/test_js_package.py
rx.ui.switch is a native input, and React refuses a child of one with an
error that takes the page down, so rx.ui.switch("Sync settings") left a
blank page. rx.switch renders the button of Radix, which drops the text.
The switch and the color mode switch now fail to compile and name the label
to put the text in, which the shared app's form now uses; the difference is
recorded as a children entry of the allowlist.
Every other rx.ui component either renders a text child where its element
takes one or refuses it while compiling, which a test over each now holds.
Claude-Session: https://claude.ai/code/session_014AwvTPQrAAUS9U2MqKfT3k
The trigger rx.ui.tooltip makes of its child named itself rx.ui.tooltip_trigger, which no app writes. Claude-Session: https://claude.ai/code/session_014AwvTPQrAAUS9U2MqKfT3k
…eflex into claude/rx-ui-ci-fixes
A line the codemod inserted or rewrote ended in LF in a file with CRLF line endings, as a checkout on Windows writes them, and its --diff printed the CR of every line. Each edit now ends its lines as the file does, and the diff is printed with the newlines of the terminal. The fixture apps and the diff are tested with both endings. Claude-Session: https://claude.ai/code/session_014AwvTPQrAAUS9U2MqKfT3k
The app root lists $/utils/refs among its window libraries since dynamic components read the registry of refs from there; the docs' frontend test evaluates the root with each library as a parameter, and lacked that one. Claude-Session: https://claude.ai/code/session_014AwvTPQrAAUS9U2MqKfT3k
…units flex(gap="3"), grid(gap="6") and center(padding="4") passed bare numbers to CSS, which the browser drops, so the rx kitchen sink rendered without that spacing, and rx.ui now refuses them, which failed the export of the size budgets. They use the spacing prop and a length in pixels. Claude-Session: https://claude.ai/code/session_014AwvTPQrAAUS9U2MqKfT3k
| ), | ||
| _sidebar(ns), | ||
| columns=rx.breakpoints(initial="1", md="2"), | ||
| spacing="6", |
There was a problem hiding this comment.
The spacing changes modify the benchmark page without updating examples/pages/.content-hash. The examples workflow runs scripts/hash_examples.py --check, which includes this file and rejects the old hash, so CI fails.
Regenerate and commit the hash with uv run python scripts/hash_examples.py.
hover.js closed the popup from a keydown listener without cancelling the key, so in Firefox and WebKit the same Escape also reached a modal dialog the popup was in, which closed with it. As the topmost layer, the popup now takes the key, as Radix's does. Claude-Session: https://claude.ai/code/session_014AwvTPQrAAUS9U2MqKfT3k
…found - theme_panel compares computed lengths as numbers, within 0.05px, rather than in Chromium's serialisation (Firefox says 21.6px, WebKit 21.59375px for 21.5938px). - context_menu asks for the menu with Shift+F10, and with the context-menu key where the engine sends no contextmenu for Shift+F10; its keys cell waits for the area to say it is open before the capture reads it. - wait_for_text says what the element held when the wait ends without the text, and the drawer's Tab step names what has the focus outside its panel, so a failure in an engine tells what happened. Claude-Session: https://claude.ai/code/session_014AwvTPQrAAUS9U2MqKfT3k
Both systems move the indicator with a 120ms transform transition, which Firefox still lists among the animations as the page settles. The step now waits, for at most two seconds, until no transition runs on the indicator, then reads every animation as before. Claude-Session: https://claude.ai/code/session_014AwvTPQrAAUS9U2MqKfT3k
…Chromium - Firefox and WebKit take a closing modal dialog out of the top layer at once, without CSS overlay, so a drawer's panel ran no transition and its on_animation_end(false) never came. A dialog that closes now gives a panel with a transform transition that is not running the transitionend the browsers that run it send. - WebKit made the drawer's dialog, which covers the page around its panel, a stop of Tab. It is out of the order of Tab; showModal still moves the focus into the panel. Claude-Session: https://claude.ai/code/session_014AwvTPQrAAUS9U2MqKfT3k
A popup recorded Escape as what closed it only from its own keydown, so one the browser dismissed on an Escape pressed before the focus had moved in was said to be dismissed from outside. popup.js now notes an Escape on the page, and the first popup that closes in its task was closed by it; popups, menus and selects take what closed them from closedBy(). Claude-Session: https://claude.ai/code/session_014AwvTPQrAAUS9U2MqKfT3k
…r cards on focus - The transitionend a dialog gives a panel that does not slide out came before the dialog said it had closed, where a transition that runs ends after: it is now sent last. - The focus-visible cells of the hover card matrix captured Radix's card before it had opened: Radix opens it a task after the focus, rx.ui at once. The cell now waits for the card, as the hover and open cells do. Claude-Session: https://claude.ai/code/session_014AwvTPQrAAUS9U2MqKfT3k
format_library_name split `pkg@1.0.0/sub` at the last @ and dropped everything after it, so a component with that library imported from `pkg`. The subpath after a version now stays, unless the specifier is a location (a path, a protocol or a git ref), whose slashes are its own. The installer reads the package from either form. Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v
The three components render the React parts of @ui-sdk/react 0.1.0-beta.17 (pinned, installed only by a page that renders one) with rx.ui's StyleX classes; their hand-written behaviour goes (tabs.js; dialog.js, menu.js and popup.js stay for alert_dialog, drawer, context_menu, popover and select). - SDKPart: a part of UI SDK styled as any rx.ui element; a trigger or a close button renders as its child through `render`, and the page collects that child's styles, custom code and app styles. - The events Radix fires on the content of a dialog or a menu are called by the reason UI SDK gives for a change, before the change, as in Radix. - A dialog is UI SDK's backdrop and its content, the panel, in the top layer; a dropdown menu is placed by UI SDK with Radix Themes' offsets. - UI SDK's state attributes (data-open, data-highlighted, data-disabled, data-ending-style) select the styles; base.css places the ui-sdk cascade layer under rx.ui's. - The parity harness reads UI SDK's markup; the allowlist drops the entry for Tab leaving a dialog, which UI SDK keeps inside as Radix. Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v
An unselected panel of UI SDK's tabs is not in the page, as in Radix, and a button that opens a popup selects UI SDK's data-open beside Radix's data-state: the declarations of the app's memoized components follow. Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v
All four render UI SDK's parts in rx.ui's look, so no native popover or dialog is left under the dialog family and the select inside a dialog no longer closes it with Escape. - _sdk: one popup root that calls the Radix events of its content by the reason of a change, Radix defaults where UI SDK's differ (menus and the select stop at their ends), and placed content with Radix Themes' offsets; a trigger's child brings its hooks and is written to JSX only when it renders. - _dialog: the parts dialog, alert_dialog and drawer share. The cancel button of an alert dialog takes the focus; a drawer's edge is UI SDK's side and the end of its slide onOpenChangeComplete, and a drawer that is not modal draws no overlay. - select: UI SDK renders the chosen option and the form input; position="item-aligned" is alignItemWithTrigger. - Allowlist: the approved phase-1 entries, the same categories for the wave, entries for the differences found (Tab leaves an open select, a drawer's close button closes it when not dismissible, the drawer fades under reduced motion), stale entries removed, reasons rewritten for UI SDK. Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v
The menus share the parts of @ui-sdk/react/menu: the context menu opens from MenuContextTrigger, and a checkbox item closes its menu and keeps its own state, as in Radix. The hover card and the tooltip are the parts of UI SDK, with the delays and placement of Radix Themes; a tooltip describes its child. The popup behaviour scripts and the native-popover style tables are gone. Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v
…ces of wave B A label of a menu is an element of its own, as in Radix: UI SDK's label must be inside a group. The arrow keys of a context menu stop on a disabled item, a tooltip closes when a press ends, and one the pointer cannot rest on stays open while the pointer is over it. The trigger of a popover names it by the id its content is given, while it is open. Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v
… shared app A context menu asked for from the keyboard opens beside its area, where UI SDK puts it. Regenerate the stubs and the differences of the migration guide, and hold the shared rx.ui app to the select trigger, the context menu and the hover card on UI SDK. Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v
The accordion is the parts of @ui-sdk/react/accordion: a heading around a button, a panel UI SDK mounts while it is open; a single accordion keeps its open item open unless it is collapsible, and Tab passes the trigger of a disabled item, as in Radix. The slider is UI SDK's, its thumbs travelling as far as Radix Themes'. The segmented control is UI SDK's, its arrow keys moving the focus without choosing and Enter, Home and End doing what they do in Radix; what marks the chosen item is placed by CSS before the page hydrates. The accordion, slider and roving-focus scripts are gone; the radio group and radio cards stay native. Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v
The avatar is the parts of @ui-sdk/react/avatar, which shows the fallback until the image has loaded. A form field is UI SDK's field: a message with a condition is its error, one without is always shown, and a label points at its control in the page the server sends. A text field with slots is UI SDK's input group. The theme panel keeps its class swap as an app script, its tooltips UI SDK's. The form-validity, image-status and text-field scripts are gone. Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v
The README says how a component is made of the parts of UI SDK; the docs and the migration guide say what renders what, with the sizes of the kitchen sink measured again. One breaking news fragment says behaviour comes from UI SDK pinned at 0.1.0-beta.17 and what a user may notice, and the fragments of the waves no longer describe the scripts it replaced. The size budgets of the kitchen sink are the measured values + 5 %. The reasons of the allowlist that still described native elements say what UI SDK does. Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v
Enter, Home and End on a segmented control and Tab passing a disabled accordion header were behaviour written beside UI SDK; UI SDK's own is kept, and the differences are allowlisted with their reasons. Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v
| if position is None or position == "popper": | ||
| return tag | ||
| if isinstance(position, Var): |
There was a problem hiding this comment.
Bound select positions break compilation
Passing a state-bound position to rx.ui.select now fails during compilation. SelectContent._render() compares position with "popper" before checking whether it is a Var. That comparison produces another Var, which Python cannot use in an if.
Check for Var first so the existing alignItemWithTrigger expression can be emitted.
| size = literal(size) | ||
| return -4 * int(size if size in ("1", "2") else 2) |
There was a problem hiding this comment.
Bound menu sizes break compilation
A state-bound menu size now fails when raised() calculates the default alignOffset. The membership check size in ("1", "2") truth-tests comparisons with the Var. This affects context menus and submenus that inherit a state-bound size, stopping the app from compiling.
Handle a Var separately and emit the offset as a browser expression.
…acts - UI SDK parts are imported under UISDK-prefixed names: the docs app, which renders Base UI's Popover beside rx.ui.popover, failed to compile on the two imports of `Popover`. - The difference of the harness's text_field reaches the page of rx.ui.input, which documents it; the docs test reads the components the pages render. - Remove the dropdown_menu style entry for the scrolling menu, which no longer differs. - A step of a contract waits 10 seconds by default rather than 30, so an allowlisted step that fails by design costs a third: WebKit ran past the job's 30 minutes. - Firefox and WebKit send no contextmenu for the keys Playwright presses; the area is sent the one a browser sends for them, as from the keyboard. - Allow Shift+Tab staying on the selected tab of rx.tabs in Firefox. Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v
Radix adds the scrollbar of a menu whose items overflow, and Radix Themes the room for it, once it has measured the items: a capture taken before missed the 4px the allowlist explains, so the entry read as stale on one machine and was needed on another. The capture now waits for it, and the entry is back. Claude-Session: https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v
Draft, work in progress. One PR for the whole
rx.uiplan for now; it may be split along the step boundaries below later, so each step lands as its own merge commit.What this is
reflex-components-ui, exposed asrx.ui: a compiled component set. The Reflex compiler emits plain HTML elements with static class names, StyleX compiles the styles in the app's own Vite build into one small stylesheet, and interactive behaviour comes from UI SDK (@ui-sdk/core+@ui-sdk/react, pinned at 0.1.0-beta.17), loaded per component only by pages that render it. rx.ui carries no re-implementation of primitives; the only script of its own left is the theme panel's. Props match today's Radix-backedrx.*and the visual target is pixel parity with Radix Themes, so moving a component is an import change.reflex-components-radixis not touched.It also carries three fixes to Reflex's JS shell that every existing app gets, independent of the new package.
Steps
Shell (all existing apps):
Foundation:
Plugin.get_vite_plugins()hook inreflex-baserx.uinamespace, JS tooling in CIUIPlugin: StyleX in the build,rx.ui.boxas a plain elementrx.ui.themestyleComponents (57 of 57):
Proof and adoption:
UI SDK
The first version of the components drove their behaviour with hand-written scripts (native popover,
<dialog>, roving focus, listbox, menus, sliders...). To avoid maintaining a second implementation of primitives, every interactive component now renders UI SDK's parts with rx.ui's StyleX classes: tabs, dropdown and context menus, dialog, alert dialog, drawer, popover, select, hover card, tooltip, accordion, slider, segmented control, avatar, form fields and messages, text field slots. Native checkbox, switch, radio group and radio cards stay native (no script).Cost: the kitchen sink ships 269.2 kB gzipped JS with rx.ui against 240.7 kB with rx (171.3 kB before UI SDK); a page without interactive parts is unchanged.
Behaviour differences from Radix that users will notice, all in the allowlist with reasons: dialogs, menus, popovers, selects, accordions and segmented controls need hydration (as Radix); disabled tabs, menu items and accordion headers take focus (ARIA patterns); Tab closes an open menu or select; tabs without a value select the first tab; Enter does not choose a segmented-control item and Home/End do nothing there; form messages follow typing after a failed submit; tooltips close when a press ends; drawers fade under reduced motion.
CI state
On 4297858 (the UI SDK move): unit tests, size budgets, builds, CodSpeed and CodeQL pass; the docs tests, one parity shard and the Firefox/WebKit contracts are being fixed. Firefox and WebKit could not be run outside CI.
Needs a maintainer's eye
frontend_lazy_bundled_libraries=True,breakingfragment).pointerdown, key presses and typed input are not."blue", not Radix's indigo. Since step 14, theappearanceof theUIPlugintheme sets the app's default color mode.Varalways wins over a later keyword argument (inline style against a class).rxpixel for pixel. The Radix margin and padding shorthands (m,px, ...) and lengths without a unit (gap="2") are refused with the spelling that works, becauserxsilently drops them. Text given torx.ui.switch(...)is refused with the label to wrap it in, becauserx.switchdrops it.parity/allowlist.toml) holds 158 entries, each with its reason: UI SDK behaviour (above), steps the Radix reference itself fails in one engine, and the differences below. The harness waits for 500 ms without DOM mutations before reading a page (a time constant).rx.ui.form(UI SDK has no API for it).rx.ui.container(stack_children_full_width=True)raises and says how to get the same result.scroll_areascrolls natively (no drawn scrollbars;typeandscroll_hide_delayhave no effect) and is a tab stop, which Radix's is not;progressis adivwith progressbar ARIA.rx.uicomponents with conditional styles (buttons, 12 of the 13 form controls) raise aStyleErrorwhen stored in state as a component.BackendDisabledoverlay (default on Reflex Cloud), the connection banner and the connection modal still usecssprops, and anrx.iconon a page brings Emotion'sjsx, so such pages still ship Emotion.Landed so far
1. Dynamic-component libraries load on demand. Blank app JS (gzip of every client
.js): 239.8 kB to 170.8 kB.frontend_lazy_bundled_librariesnow defaults toTrue: a custom script that reads a library fromwindow.__reflexmust firstawait window.__reflex_load([...]), or the app sets the flag toFalse.2. Scripts start after first paint on prerendered pages. Lighthouse mobile on the blank app: simulated 90 / LCP 2.85 s to 100 / 1.21 s; throttled 88 / 2.99 s to 98 / 1.75 s; CLS 0. Dev mode and client-rendered routes are untouched. A dev checkout with an existing
.webneedsreflex initafter pulling this.3. State runtime and toaster ship only when used.
rx.el-only app: stateless 158.7 kB to 130.8 kB, stateful with no toast 161.6 kB to 153.9 kB. A stateless app keeps the event runtime off pages without handlers.refsimported from$/utils/state(as published packages do) is redirected to$/utils/refs, so it loads no state runtime.4. Vite plugin hook.
Plugin.get_vite_plugins()returnsrx.plugins.VitePluginEntry(call=..., imports=[...]); with no entriesvite.config.jsis byte-identical to before.5. Package scaffold.
packages/reflex-components-ui, the optional extrareflex[ui], lazyrx.ui(no cost atimport reflex), a JS package with lint, strict type-check, a generator drift check and vitest in a gated CI job. The extra is unpinned until the package has a first release.6.
UIPlugin. StyleX runs in the app's Vite build through a shipped wrapper.base.cssdeclares the cascade once: resets, then UI SDK, thenreflex-ui, then Tailwind's components and utilities, with unlayered CSS on top; verified with Tailwind v4 (v3 has no native layers and wins overrx.ui).7. Tokens and themes. 81 StyleX modules generated from the installed
@radix-ui/themestoken CSS, drift-tested. A Chromium sweep against the real stylesheet: 10,556 theme combinations x 1,068 custom properties, sRGB and display-P3, zero differences.UIPlugin(theme=rx.ui.Theme(...)),rx.ui.theme(...), typedrx.ui.tokens,color_schemeandradiuson components. Root theme: 4.6 kB gzipped CSS, 0.6 kB gzipped JS.8. Style compiler and typed styles. Tables and user styles are merged in Python, user last, and emitted as literal StyleX declarations that fold to class strings; state values become inline CSS variables, state-bound variants become tables of class strings; no page ships the StyleX runtime.
styleis typed from a generatedStyleProps(521 properties); misuse is a compile error naming the component as the app writes it (rx.ui.callout.root).keyframes({...})animates. Compile time 0.7x to 0.99x of the Emotion path.9. Parity harness.
uv run python scripts/ui_parity.py [component] [--fonts TEXT CODE] [--shard i/n]compares pixels, computed styles (including elements inside a cell where the trees correspond, and named parts down to pseudo-elements) and the accessibility tree against the Radix-backed component, runs a behaviour contract against both systems, and writes a browsable report. CI:ui-parity(Chromium, three shards balanced by recorded timings) andui-contracts(Chromium, Firefox, WebKit), all gated. A Playwright check loads every page of the shared test app in dev and prod and fails on any console warning or error.10 to 14. Components. All 57: layout and typography (19), display and actions (12), form controls (13), overlays and disclosure (10: tabs, accordion, dialog, alert dialog, drawer, popover, tooltip, hover card, dropdown menu, context menu), and app-level (theme panel, color-mode button and switch). Each has its namespaces and parts and is based on the same HTML element classes as the Radix wrappers, so props match (API parity test). Every non-allowlisted parity cell is within its matrix's tolerance, most at exactly zero. Native checkbox, switch and radio controls work with JavaScript disabled. Interactive components run on UI SDK (see above).
15. Benchmarks and budgets.
examples/pages/holds blank,rx.elstateless and stateful, onerx.uibutton, and the same kitchen sink inrxand inrx.ui.uv run reflex-bench run --suite pagesmeasures them, andpackages/reflex-bench/budgets.jsonfails CI on overshoot. Gzipped JS: kitchen sink 240.7 kB withrx, 269.2 kB withrx.uion UI SDK (CSS 82.4 kB to 22.6 kB, zero Emotion files); onerx.uibutton 146.8 kB;rx.elstateless first page 124.5 kB.16. Emotion-free pages. A generated module imports React's
createElementunless its code has acssprop, decided once per module from its code. Anrx.ui-only app: 157.7 kB to 149.6 kB gzipped JS, with a permanent test that no script contains Emotion. Compile benchmarks are level withmain.17. Migration codemod and guide.
python -m reflex_components_ui.migrate <paths> [--check] [--diff] [--fix-spacing]rewritesrx.*Radix components torx.ui, moves the theme torx.plugins.UIPlugininrxconfig.py, and reports with file, line and column every style or prop it cannot carry over. The migration guide's table of API differences is generated from the allowlist.18. Docs.
rx.uidemos on 51 library pages, beside theirrxcounterparts, plus an overview and styling and theming guides (what the style compiler accepts and refuses, tokens, themes, color mode).All Submissions:
Type of change
New Feature Submission:
Changes To Core Features:
https://claude.ai/code/session_014AwvTPMyGMj9KHaq66r64v