Native UI Book · GPUI-Kit

Native UI 原生组件手册 (GPUI-Kit)

内置 60+ 生产级组件,通过 gpux::kit(兼容易用别名 gpux::component)导出。所有组件直接编译为 Metal / Vulkan / DX12 / XComponent / WebGPU 着色器图元,零 HTML/CSS 开销,内置 ActiveTheme 深浅色语义令牌与 Sizable 尺寸体系。

实时原生窗口预览 (Live Window Preview)

GPUI-Kit Component Showcase · 8-Target Native GPU Instanced
Buttons & Variants
Primary Ghost Danger
Telemetry Progress & Switch
GPU Batch Fill84%

统一组件导入与主题令牌 (`ActiveTheme`)

在启用 gpui-backend 时,你可以通过 gpux::kit 访问所有原生组件、布局辅助函数(v_flex, h_flex)以及 cx.theme() 语义颜色令牌:

rust
use gpux::prelude::*;
use gpux::kit::button::{Button, ButtonVariants};
use gpux::kit::{h_flex, v_flex, ActiveTheme, Sizable, StyledExt};

fn render_toolbar(cx: &mut Context<Self>) -> impl IntoElement {
    h_flex()
        .w_full()
        .px_4()
        .py_3()
        .justify_between()
        .items_center()
        .bg(cx.theme().title_bar)
        .border_b_1()
        .border_color(cx.theme().border)
        .child(v_flex().child("Cluster Telemetry").text_color(cx.theme().foreground))
        .child(
            Button::new("sync-nodes")
                .primary()
                .small()
                .label("Sync 128 Nodes")
        )
}

组件分类目录