gpui-kit README

The project's README from github.com/longbridge/gpui-kit. As one markdown file: README.md.

GPUI Kit logo
GPUI Kit

English | 简体中文

Build Status Docs Crates.io

Build fantastic, high-performance desktop apps with Rust and GPUI.

GPUI Kit is a comprehensive Rust desktop application framework. It combines a production-ready UI system with application-grade data, layout, and editing capabilities, all built on a reusable foundation of behavior, state, and infrastructure, and opens the finished application to JavaScript extensions.

Documentation: https://gpui-kit.com

gpui-kit             The one crate applications depend on
├── gpui-base        Unstyled behavior, state, and infrastructure
└── gpui-component   GPUI Component: the complete styled UI system

gpui-kit pins the matching GPUI release and re-exports GPUI, base, component, and assets, so a Rust application lists a single dependency. JavaScript extension hosts add gpui-shell separately; gpui-component-shell supplies the styled catalog.

See the executable application recipe and AI-assisted development acceptance checks for a tested starting point and verification commands.

Features

Framework Architecture

Three layers. One ecosystem.

Use gpui-component to keep the application coherent with one complete visual and interaction system. Use gpui-base when your product needs to create and own that system itself. Use gpui-shell when the application should be extensible in JavaScript after it ships.

gpui-component gpui-base gpui-shell
Complete, styled components Unstyled behavior and infrastructure JavaScript runtime hosted by Rust
Productive defaults with theming Full control over structure and visual design Capabilities granted one at a time
Best for building applications Best for building design systems Best for plugins and scripted applications
                             APPLICATION
                                  │
              ┌───────────────────┼───────────────────┐
              │                   │                   │
              ▼                   ▼                   ▼
    ┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
    │  gpui-component  │ │ Your Design      │ │    gpui-shell    │
    │    Styled UI     │ │ System           │ │  JS extensions   │
    └────────┬─────────┘ └────────┬─────────┘ └────────┬─────────┘
             │                    │                    │
             └────────────────────┼────────────────────┘
                                  ▼
                        ┌──────────────────┐
                        │    gpui-base     │
                        │ Behavior · State │
                        │ Infrastructure   │
                        └────────┬─────────┘
                                 ▼
                               GPUI

Behavior belongs to the foundation. Presentation belongs to the application.

Use gpui-component when you want polished controls ready to ship. Build on gpui-base when your application should own its component source, layout, styling, and motion while reusing difficult interaction behavior. Add gpui-shell when contributors should extend the product without a fork or a release.

The layering follows the same separation that makes the shadcn ecosystem flexible:

GPUI Kit ecosystem Web ecosystem
GPUI HTML + Tailwind CSS
gpui-base Base UI
gpui-component shadcn's styled component layer

Explore the architecture →

Showcase

GPUI Kit has powered Longbridge Pro from day one. The framework is extracted from the demands of a publicly shipped commercial desktop application rather than designed in isolation.

GPUI provides the rendering foundation. Longbridge provides the production foundation.

Image

Usage

[dependencies]
gpui-kit = "0.6"

gpui-kit always brings in GPUI and gpui-base; gpui-component and the default icon set are on by default. Turn default features off to keep only the layers you use. The gpui-component features (inspector, decimal, tree-sitter, and each tree-sitter-<language>) are available under the same names.

Basic Example

use gpui_kit::component::button::*;
use gpui_kit::component::*;
use gpui_kit::*;

pub struct HelloWorld;
impl Render for HelloWorld {
    fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
        div()
            .v_flex()
            .gap_2()
            .size_full()
            .items_center()
            .justify_center()
            .child("Hello, World!")
            .child(
                Button::new("ok")
                    .primary()
                    .label("Let's Go!")
                    .on_click(|_, _, _| println!("Clicked!")),
            )
    }
}

fn main() {
    gpui_kit::application().run(move |cx| {
        // This must be called before using any GPUI Component features.
        gpui_kit::init(cx);

        cx.spawn(async move |cx| {
            cx.open_window(WindowOptions::default(), |window, cx| {
                let view = cx.new(|_| HelloWorld);
                // This first level on the window, should be a Root.
                cx.new(|cx| Root::new(view, window, cx))
            })
            .expect("Failed to open window");
        })
        .detach();
    });
}

Icons

The default assets feature bundles the Lucide icon set as gpui-kit-assets; pass it to the application with gpui_kit::application().with_assets(gpui_kit::assets::Assets). To ship your own icons instead, leave that feature out and name the SVG files as defined in IconName.

Skills for AI Coding Agents

Install the GPUI Kit skills for your AI coding agent (Cursor, Claude Code, Gemini CLI, Codex, etc.):

npx skills add longbridge/gpui-kit
Skill Description
gpui-kit Setup, component catalog, usage patterns, GPUI mechanics (elements, entities, async, focus, actions, tests), and the Coding Guides.
gpui-kit-design-guides The Design Guides: layout, spacing, hierarchy, interaction states, overlays, and interface copy.

Development

Desktop Gallery (Story)

The story crate is a gallery application that showcases all available components. Run it with:

cargo run

Examples

Some larger examples reuse the story gallery components and run as standalone packages:

# Dock layout system (panels, split views, tabs)
cargo run -p example-dock

# Markdown rendering
cargo run -p example-markdown

# HTML rendering
cargo run -p example-html

The examples directory also contains standalone examples, each focused on a single feature. Each example is a separate crate, run them with cargo run -p <name>:

# Code editor with LSP support and syntax highlighting
cargo run -p example-editor

# Basic hello world
cargo run -p hello_world

# System monitor (real-time charts with CPU/memory data)
cargo run -p system_monitor

# Window title customization
cargo run -p window_title

Check out CONTRIBUTING.md for more details.

Compare to others

See the comparison with Iced, egui and Qt 6 on the site.

License

Apache-2.0

gpui-kit (longbridge/gpui-kit)

Searching Database…

这是什么?GPUI Kit 是一个 Rust 框架,基于 GPUI(Zed Industries 的 UI 引擎)构建跨平台桌面应用。它结合了带样式的组件库、无界面的行为层,以及一个让应用向 JavaScript 开放的扩展层。
这是一个库,还是我需要从几个层中选择?它是分层设计的:gpui-base 提供无界面的交互行为,gpui-component 在它之上提供精致的带样式控件,gpui-shell 让贡献者无需 fork 就能扩展产品。你可以自行选择应用依赖哪些层。
如何把它添加到 Rust 项目中?将 gpui-kit 添加为 Cargo 依赖。默认情况下会引入 GPUI、gpui-base、gpui-component 以及内置的 Lucide 图标集。如果只想保留实际用到的层,可以关闭默认功能。
我需要先掌握 Rust 和 GPUI 吗?需要。它直接构建在 GPUI 之上,因此你需要熟悉 Rust 和 Cargo,并了解 GPUI 的元素(elements)、实体(entities)、异步模型、焦点(focus)和动作(actions)。
我可以用自己的图标集替换内置的吗?可以。不启用默认的 assets 功能,然后用你自己的 SVG 文件,并让文件名与 IconName 中定义的标识符一致,即可替代内置的 Lucide 图标集。
哪些 AI 编程助手有针对本框架的官方技能?GPUI Kit 为 Cursor、Claude Code、Gemini CLI 和 Codex 提供可安装的技能,涵盖安装配置、组件目录、GPUI 机制以及设计指南。
这个框架在真实产品中经过验证了吗?经过了。GPUI Kit 从第一天起就为 Longbridge Pro 提供支持,这是一款已正式商用的桌面交易应用。因此它是从真实的生产需求中提炼出来的,而不是闭门设计的。
它与其他 Rust GUI 框架相比如何?项目文档网站提供了与 Iced、egui 和 Qt 6 的直接对比。
组件的外观和手感来自哪里?组件样式基于 shadcn/ui(部分组件参考了 Reui),默认图标集使用 Lucide 图标。
Creator
longbridge
Size
36.6 MB
Stars
18K
Age
2y
Commits · 90 Days