gpui-component
Use native controls from gpui-component through GPUI Kit (gpui::component) so your application and its components always share one GPUI engine instance. Try the component binary from Runnable Demos to see Button, Input, and Popover working together.
1. Unified Dependency Setup
Section titled “1. Unified Dependency Setup”Depend on gpui-kit aliased as gpui:
[dependencies]gpui = { package = "gpui-kit", version = "=0.10.0" }gpui-rsx = "0.13.0"GPUI Kit exports styled controls via gpui::component, unstyled primitives via gpui::base, and icon assets via gpui::assets. Before opening windows, call gpui::init(cx) and mount views with gpui::open_window(...).
2. Constructing Controls: <Tag(...)> vs base={...}
Section titled “2. Constructing Controls: <Tag(...)> vs base={...}”Constructor shorthand (recommended)
Section titled “Constructor shorthand (recommended)”Pass Type::new(...) arguments directly in parentheses after the tag name:
use gpui::component::button::{Button, ButtonVariants as _};use gpui::component::Sizable as _;
rsx! { <Button("save") label="Save" small primary />}// Expands to:// Button::new("save").label("Save").small().primary()- Uppercase paths expand
<Button("save") />toButton::new("save")and<Tab() />toTab::new(). - Lowercase paths call the function directly (
<widget("a") />→widget("a")).
Preconfigured builders with base={...}
Section titled “Preconfigured builders with base={...}”Use the macro-only base attribute when you already have a builder expression or need component methods whose names collide with GPUI stateful attributes:
// Tab::aria_label is a component builder method, not GPUI's stateful aria_labelrsx! { <Tab base={Tab::new().label("Overview").aria_label("Overview tab")} underline />}3. Import Extension Traits
Section titled “3. Import Extension Traits”Many gpui-component styling and variant methods (such as .primary() or .small()) live on extension traits. Import them near your RSX view so generated chains type-check cleanly:
use gpui::component::button::{Button, ButtonVariants as _};use gpui::component::Sizable as _;4. Verify Single Engine Identity
Section titled “4. Verify Single Engine Identity”If Rust reports mismatched GPUI types between your app and a component, check for duplicate gpui-pre crate instances first:
cargo check --manifest-path demo/Cargo.toml --bins --lockedcargo xtask check-gpuicargo tree --manifest-path demo/Cargo.toml --locked -i gpui-preCommit your Cargo.lock so all contributors resolve the same unified Kit graph.