Skip to content

Troubleshooting

Start with the error reported by Rust or cargo rsx lint, then find the matching section below. For dependency failures, check the verified dependency set before changing the lockfile.

Example error:

Closing tag `</span>` does not match opening tag `<div>`.

Fix the nesting:

// Wrong
rsx! {
<div>
<span>{"Text"}</div>
</span>
}
// Correct
rsx! {
<div>
<span>{"Text"}</span>
</div>
}

Add the missing closing tag:

// Wrong
rsx! {
<div>{"Content"}
}
// Correct
rsx! {
<div>{"Content"}</div>
}

Bare identifiers are not children. Wrap expressions in braces:

// Wrong
rsx! { <div>count</div> }
// Correct
rsx! { <div>{count}</div> }

String literals can be written directly:

rsx! { <div>"Count"</div> }

The loop body must be a braced RSX body:

// Wrong
rsx! {
<ul>
{for item in items
<li>{item}</li>
}
</ul>
}
// Correct
rsx! {
<ul>
{for item in items {
<li>{item}</li>
}}
</ul>
}

rsx_strict! rejects unsupported static classes:

rsx_strict! {
<div class="md:flex" />
}

Use a supported class, a direct GPUI method, when, or rsx_permissive! if ignoring unsupported classes is intentional.

Arbitrary length classes must use supported units and finite values:

// Correct
rsx! { <div class="w-[280px] max-w-[37.5%] gap-[14px]" /> }

Sizing supports px, rem, percentages, and fractions. Spacing supports definite lengths such as px and rem; percentage spacing is rejected.

Use supported hex, RGB, or RGBA forms:

rsx! {
<div class="bg-[#ff0000] text-[rgb(15,23,42)] border-[rgba(15,23,42,0.35)]" />
}

RGBA alpha must be in the 0.0..=1.0 range.

Dynamic classes use a runtime matcher. Unsupported tokens are ignored in permissive mode and warn once per call site in debug builds.

If a dynamic class must always be applied, prefer one of these:

rsx! {
<div
class="flex"
w={px(width)}
whenClass={(active, "bg-blue-500 text-white")}
/>
}

Use rsx_strict! to panic when an unsupported dynamic token is evaluated.

State Class Attribute Uses a Dynamic Value

Section titled “State Class Attribute Uses a Dynamic Value”

hoverClass, focusClass, and activeClass are compile-time helpers and only accept string literals:

// Wrong
let classes = "bg-blue-600";
rsx! { <button hoverClass={classes} /> }
// Correct
rsx! { <button hoverClass="bg-blue-600" /> }

Use hover, focus, or active directly when the refinement needs Rust logic:

rsx! {
<button hover={|style| style.bg(rgb(0x2563eb))} />
}

State Class Contains an Element-Level Class

Section titled “State Class Contains an Element-Level Class”

State class attributes receive a GPUI StyleRefinement, so element-level classes such as overflow-scroll or debug-outline cannot be applied there:

// Wrong
rsx! { <button activeClass="overflow-scroll" /> }

Put always-on element behavior on the main class:

rsx! {
<button
class="overflow-scroll"
activeClass="opacity-75"
/>
}

For conditional element-level behavior, provide an explicit id and call GPUI through when:

rsx! {
<button
id="results"
when={(is_scrollable, |el| el.overflow_scroll())}
activeClass="opacity-75"
/>
}

These attributes expect exactly two tuple values:

rsx! {
<div when={(active, |el| el.bg(rgb(0x3b82f6)))} />
<div whenSome={(width, |el, w| el.w(px(w)))} />
<div whenClass={(active, "bg-blue-500 text-white")} />
}

This is invalid:

let classes = "bg-blue-500";
rsx! {
<div whenClass={(active, classes)} />
}

Use when for dynamic styling, or put the literal directly in whenClass.

overflow-scroll, overflow-x-scroll, and overflow-y-scroll need ID semantics. Use when with explicit GPUI calls:

rsx! {
<div when={(scrollable, |el| el.overflow_scroll())} />
}

Repeated stateful elements need unique IDs:

// Wrong
rsx! {
<ul>
{for item in &self.items {
<li onClick={handler}>{item.name.as_str()}</li>
}}
</ul>
}
// Correct
rsx! {
<ul>
{for item in &self.items {
<li key={item.id} onClick={handler}>{item.name.as_str()}</li>
}}
</ul>
}

key only matters when the element needs an ID. On plain layout rows, it is ignored.

Auto IDs include source file, line, and column. If identity must survive moving code, use an explicit id:

rsx! {
<button id="settings-save" onClick={handler}>
{"Save"}
</button>
}

Children must be valid GPUI child values. Handle Option values explicitly:

rsx! {
<div>{self.optional_text.as_deref().unwrap_or("")}</div>
}

Or render conditionally:

rsx! {
<div>
{if let Some(text) = &self.optional_text {
rsx! { <span>{text.as_str()}</span> }
} else {
rsx! { <span /> }
}}
</div>
}

Iterate by reference:

rsx! {
<ul>
{for item in &self.items {
<li>{item.name.as_str()}</li>
}}
</ul>
}

Fragments expand to vec![...]. If root element concrete types differ, wrap them or erase the type:

rsx! {
<div>
{self.render_header()}
{self.render_custom_button()}
</div>
}

After mutating view state, call cx.notify() once:

onClick={cx.listener(|view, _, _window, cx| {
view.count += 1;
cx.notify();
})}

Also check that the rsx! expression is returned from render without a trailing semicolon:

fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
rsx! { <div>{"Content"}</div> }
}

Dioxus CLI 0.7.10 recognizes macros named rsx! or render! by the last segment of their path. This also matches gpui_rsx::rsx!. Its template parser rejects GPUI-RSX’s HTML-like syntax, and the CLI skips that macro instead of falling back to Rust compilation. GPUI’s Subsecond integration therefore receives no Rust patch for an edit confined to that macro.

Use a local alias to make the edit follow the Rust compilation path:

use gpui::prelude::*;
use gpui_rsx::rsx as gpui_view;
fn content() -> impl gpui::IntoElement {
gpui_view! { <div>{"Edit this text"}</div> }
}

Restart dx serve after changing the import and call sites. Keep hot reloading enabled: in CLI 0.7.10, --hot-reload false disables processing file changes, including automatic Rust patches. The alias preserves the selected macro’s class handling mode. The default rsx! is permissive; for strict checking, import gpui_rsx::rsx_strict as gpui_view instead.

The alias addresses change detection. Applying the patch also requires a GPUI version with Subsecond support and an application feature forwarding to gpui/hot-reload, enabled with dx serve --hot-patch --hot-reload true --features hotreload. Check dx --version and distinguish a missing rebuild from a generated patch that fails to update the window. These are separate stages.

The standalone fixture in tests/fixtures/hot-reload/ pins GPUI Pre 0.3.12 and Dioxus 0.7.10. Its README provides parser tests and native builder, original macro and alias comparisons. It is separate from the demo’s verified dependency set. Its kit feature checks Kit 0.10.0 initialization and root-window mounting. From the repository root, node scripts/test-hot-reload.mjs uses Dioxus CLI 0.7.10 to edit a temporary copy and check revision, PID and timer state in native render callbacks. It does not click controls or compare pixels. The development CLI’s cargo rsx dev --check or doctor --hot-reload --features hotreload,kit checks readiness separately; passing that check does not mean a patch was applied. The existing build/restart workflow can also reload edits by restarting the process, which resets application state.

Check the handler signature expected by the GPUI method you are calling. For repeated stateful event targets, ensure the element has a key or explicit id.

groupDragOver is not exposed as an RSX attribute because GPUI needs the drag data type at the call site:

// Wrong
rsx! {
<div groupDragOver={("items", |style| style.opacity(0.75))} />
}

Call GPUI directly through when or base so the type parameter is explicit:

rsx! {
<div
when={(drag_enabled, |el| {
el.group_drag_over::<MyDragData>("items", |style| style.opacity(0.75))
})}
/>
}

Use rsx_expand! to inspect generated methods:

let preview = gpui_rsx::rsx_expand! {
<div class="flex gap-4 bg-blue-500" />
};

Remember that GPUI-RSX is not Tailwind CSS. State variants such as hover:bg-blue-500 map to GPUI’s .hover(...), but responsive and media variants such as md: and dark: have no GPUI equivalent; compute the condition and use when instead.

If gpui-component types do not match your application types, inspect the dependency tree:

Terminal window
cargo tree --manifest-path demo/Cargo.toml --locked -i gpui-pre

Use the single Kit dependency shown in Compatibility and import components through gpui::component. In this repository, cargo xtask check-gpui validates the matching snapshot and shared engine types.

Demo Check Fails After Updating Dependencies

Section titled “Demo Check Fails After Updating Dependencies”

Run:

Terminal window
cargo check --manifest-path demo/Cargo.toml --bins --locked

If --locked fails because the lockfile needs changes, decide whether the GPUI target revision should intentionally move. Do not update the lockfile casually for application compatibility checks.

When filing an issue, include:

  • GPUI-RSX version.
  • The resolved GPUI snapshot version and source from cargo tree -i gpui-pre.
  • Minimal RSX snippet.
  • Full compiler error or runtime symptom.
  • Whether the issue reproduces in the demo/ crate.