BlueGit

ict rusty-teams

Files

rusty-teams / vendor / gpui-component / README.md

README.md

README.md 12.1 KiB Download Raw

GPUI Kit logo
<strong>GPUI Kit</strong>

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. GPUI Kit ships 75+ documented components and primitives, WebAssembly support, AccessKit accessibility, UI integration testing, and an optional JavaScript extension runtime.

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

  • 75+ Components and Primitives: Forms, navigation, overlays, data display, editing, feedback, and layout, with polished interactions and productive defaults.
  • Production Ready: Used to build Longbridge Pro from day one and continuously refined in a publicly shipped commercial desktop application.
  • WebAssembly: Run applications and the same component showcases on the web with wasm32-unknown-unknown.
  • Accessibility: AccessKit roles, names, states, relationships, and actions are built into the interaction layer and covered by tests.
  • UI Integration Testing: Render real components in headless windows, drive pointer and keyboard input, and assert state, focus, layout, and accessibility.
  • Native Feel: Modern controls inspired by macOS and Windows, backed by semantic themes and multiple sizes.
  • 120 FPS: GPU-accelerated interfaces that remain smooth under load.
  • Data Tables: Virtual scrolling, fixed and resizable columns, sorting, and cell selection across hundreds of thousands of rows.
  • Virtual Lists: Render only the visible range, including lists whose items have different sizes.
  • Code Editor: Stable performance at 200K lines with Tree-sitter highlighting and LSP diagnostics, completion, and hover.
  • Dock Layout: Resizable panels, draggable tabs, nested splits, and edge docks — all serializable.
  • Rich Content: Native Markdown and HTML rendering, syntax highlighting, and built-in charts.
  • Design Freedom: Use the complete visual system or build your own on the behavior and infrastructure in gpui-base.
  • JavaScript Extensions: gpui-shell lets a shipped Rust host load panels and business logic as scripts, with every capability granted explicitly.
  • Cross Platform: Ship one Rust codebase to macOS, Windows, and Linux.

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-componentgpui-basegpui-shell
Complete, styled componentsUnstyled behavior and infrastructureJavaScript runtime hosted by Rust
Productive defaults with themingFull control over structure and visual designCapabilities granted one at a time
Best for building applicationsBest for building design systemsBest 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 ecosystemWeb ecosystem
GPUIHTML + Tailwind CSS
gpui-baseBase UI
gpui-componentshadcn'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.7"

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);

        gpui_kit::open_window(WindowOptions::default(), cx, |_, cx| {
            cx.new(|_| HelloWorld)
        })
        .expect("Failed to open window");
    });
}

gpui_kit::open_window is the application window entry point and always mounts a Base Root. Component initialization registers styled window facilities; Cargo features do not select a different root type.

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
SkillDescription
gpui-kitSetup, component catalog, usage patterns, GPUI mechanics (elements, entities, async, focus, actions, tests), and the Coding Guides.
gpui-kit-design-guidesThe 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

Software source and documentation code examples: Apache-2.0.

Documentation prose and original illustrations in the Docs, Base, Component, and Shell sections (including Chinese translations) for which GPUI Kit holds licensing rights are also offered under CC BY 4.0. When copying or adapting that material, credit GPUI Kit, link to the source page and CC BY 4.0 license, and indicate changes. Existing Apache-2.0 permissions remain; earlier revisions retain their prior terms, and third-party contributions keep their own licenses unless separately authorized. Using facts or ideas without copying protected expression does not require attribution under CC BY 4.0.

  • Built on GPUI, the UI framework from Zed Industries, also Apache-2.0. The gpui-pre-* crates are snapshots of it, published with Zed's license and notices intact.
  • UI design based on shadcn/ui, some from Reui.
  • Icons from Lucide.
Source
1<p align="center">
2 <img src="https://raw.githubusercontent.com/longbridge/gpui-kit/main/website/public/logo.svg" width="112" alt="GPUI Kit logo" />
3 <br>
4 <strong>GPUI Kit</strong>
5</p>
6
7[English](./README.md) | [简体中文](./README.zh-CN.md)
8
9[![Build Status](https://github.com/longbridge/gpui-kit/actions/workflows/ci.yml/badge.svg)](https://github.com/longbridge/gpui-kit/actions/workflows/ci.yml) [![Docs](https://docs.rs/gpui-kit/badge.svg)](https://docs.rs/gpui-kit/) [![Crates.io](https://img.shields.io/crates/v/gpui-kit.svg)](https://crates.io/crates/gpui-kit)
10
11Build fantastic, high-performance desktop apps with Rust and GPUI.
12
13GPUI Kit is a comprehensive Rust desktop application framework. It combines a
14production-ready UI system with application-grade data, layout, and editing
15capabilities, all built on a reusable foundation of behavior, state, and
16infrastructure. GPUI Kit ships 75+ documented components and primitives,
17WebAssembly support, AccessKit accessibility, UI integration testing, and an
18optional JavaScript extension runtime.
19
20Documentation: <https://gpui-kit.com>
21
22```text
23gpui-kit The one crate applications depend on
24├── gpui-base Unstyled behavior, state, and infrastructure
25└── gpui-component GPUI Component: the complete styled UI system
26```
27
28`gpui-kit` pins the matching GPUI release and re-exports GPUI, base, component,
29and assets, so a Rust application lists a single dependency. JavaScript extension
30hosts add `gpui-shell` separately; `gpui-component-shell` supplies the styled catalog.
31
32See the [executable application recipe and AI-assisted development acceptance checks](examples/ai_recipes/README.md) for a tested starting point and verification commands.
33
34## Features
35
36- **75+ Components and Primitives**: Forms, navigation, overlays, data display, editing, feedback, and layout, with polished interactions and productive defaults.
37- **Production Ready**: Used to build Longbridge Pro from day one and continuously refined in a publicly shipped commercial desktop application.
38- **WebAssembly**: Run applications and the same component showcases on the web with `wasm32-unknown-unknown`.
39- **Accessibility**: AccessKit roles, names, states, relationships, and actions are built into the interaction layer and covered by tests.
40- **UI Integration Testing**: Render real components in headless windows, drive pointer and keyboard input, and assert state, focus, layout, and accessibility.
41- **Native Feel**: Modern controls inspired by macOS and Windows, backed by semantic themes and multiple sizes.
42- **120 FPS**: GPU-accelerated interfaces that remain smooth under load.
43- **Data Tables**: Virtual scrolling, fixed and resizable columns, sorting, and cell selection across hundreds of thousands of rows.
44- **Virtual Lists**: Render only the visible range, including lists whose items have different sizes.
45- **Code Editor**: Stable performance at 200K lines with Tree-sitter highlighting and LSP diagnostics, completion, and hover.
46- **Dock Layout**: Resizable panels, draggable tabs, nested splits, and edge docks — all serializable.
47- **Rich Content**: Native Markdown and HTML rendering, syntax highlighting, and built-in charts.
48- **Design Freedom**: Use the complete visual system or build your own on the behavior and infrastructure in `gpui-base`.
49- **JavaScript Extensions**: `gpui-shell` lets a shipped Rust host load panels and business logic as scripts, with every capability granted explicitly.
50- **Cross Platform**: Ship one Rust codebase to macOS, Windows, and Linux.
51
52## Framework Architecture
53
54### Three layers. One ecosystem.
55
56Use `gpui-component` to keep the application coherent with one complete visual
57and interaction system. Use `gpui-base` when your product needs to create and
58own that system itself. Use `gpui-shell` when the application should be
59extensible in JavaScript after it ships.
60
61| **`gpui-component`** | **`gpui-base`** | **`gpui-shell`** |
62| -------------------------------- | --------------------------------------------- | ------------------------------------------ |
63| Complete, styled components | Unstyled behavior and infrastructure | JavaScript runtime hosted by Rust |
64| Productive defaults with theming | Full control over structure and visual design | Capabilities granted one at a time |
65| Best for building applications | Best for building design systems | Best for plugins and scripted applications |
66
67```text
68 APPLICATION
69 │
70 ┌───────────────────┼───────────────────┐
71 │ │ │
72 ▼ ▼ ▼
73 ┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
74 │ gpui-component │ │ Your Design │ │ gpui-shell │
75 │ Styled UI │ │ System │ │ JS extensions │
76 └────────┬─────────┘ └────────┬─────────┘ └────────┬─────────┘
77 │ │ │
78 └────────────────────┼────────────────────┘
79 ▼
80 ┌──────────────────┐
81 │ gpui-base │
82 │ Behavior · State │
83 │ Infrastructure │
84 └────────┬─────────┘
85 ▼
86 GPUI
87```
88
89> **Behavior belongs to the foundation. Presentation belongs to the application.**
90
91Use **`gpui-component`** when you want polished controls ready to ship. Build on
92**`gpui-base`** when your application should own its component source, layout,
93styling, and motion while reusing difficult interaction behavior. Add
94**`gpui-shell`** when contributors should extend the product without a fork or
95a release.
96
97The layering follows the same separation that makes the
98[shadcn](https://ui.shadcn.com) ecosystem flexible:
99
100| GPUI Kit ecosystem | Web ecosystem |
101| ------------------------------------ | ------------------------------- |
102| GPUI | HTML + Tailwind CSS |
103| [`gpui-base`](crates/base/README.md) | [Base UI](https://base-ui.com) |
104| `gpui-component` | shadcn's styled component layer |
105
106[Explore the architecture →](docs/ARCHITECTURE.md)
107
108## Showcase
109
110GPUI Kit has powered [Longbridge Pro](https://longbridge.com/desktop)
111from day one. The framework is extracted from the demands of a publicly shipped
112commercial desktop application rather than designed in isolation.
113
114> **GPUI provides the rendering foundation. Longbridge provides the production foundation.**
115
116<img width="1763" alt="Image" src="https://github.com/user-attachments/assets/e1ecb9c3-2dd3-431e-bd97-5a819c30e551" />
117
118## Usage
119
120```toml
121[dependencies]
122gpui-kit = "0.7"
123```
124
125`gpui-kit` always brings in GPUI and `gpui-base`; `gpui-component` and the
126default icon set are on by default. Turn default
127features off to keep only the layers you use. The `gpui-component` features (`inspector`, `decimal`,
128`tree-sitter`, and each `tree-sitter-<language>`) are available under the same
129names.
130
131### Basic Example
132
133```rs
134use gpui_kit::component::button::*;
135use gpui_kit::component::*;
136use gpui_kit::*;
137
138pub struct HelloWorld;
139impl Render for HelloWorld {
140 fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
141 div()
142 .v_flex()
143 .gap_2()
144 .size_full()
145 .items_center()
146 .justify_center()
147 .child("Hello, World!")
148 .child(
149 Button::new("ok")
150 .primary()
151 .label("Let's Go!")
152 .on_click(|_, _, _| println!("Clicked!")),
153 )
154 }
155}
156
157fn main() {
158 gpui_kit::application().run(move |cx| {
159 // This must be called before using any GPUI Component features.
160 gpui_kit::init(cx);
161
162 gpui_kit::open_window(WindowOptions::default(), cx, |_, cx| {
163 cx.new(|_| HelloWorld)
164 })
165 .expect("Failed to open window");
166 });
167}
168```
169
170`gpui_kit::open_window` is the application window entry point and always mounts a Base `Root`. Component initialization registers styled window facilities; Cargo features do not select a different root type.
171
172### Icons
173
174The default `assets` feature bundles the [Lucide](https://lucide.dev) icon set
175as `gpui-kit-assets`; pass it to the application with
176`gpui_kit::application().with_assets(gpui_kit::assets::Assets)`. To ship your
177own icons instead, leave that feature out and name the SVG files as defined in
178[IconName](https://github.com/longbridge/gpui-kit/blob/main/crates/component/src/icon.rs#L86).
179
180## Skills for AI Coding Agents
181
182Install the GPUI Kit skills for your AI coding agent (Cursor, Claude Code, Gemini CLI, Codex, etc.):
183
184```bash
185npx skills add longbridge/gpui-kit
186```
187
188| Skill | Description |
189| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
190| `gpui-kit` | Setup, component catalog, usage patterns, GPUI mechanics (elements, entities, async, focus, actions, tests), and the Coding Guides. |
191| `gpui-kit-design-guides` | The Design Guides: layout, spacing, hierarchy, interaction states, overlays, and interface copy. |
192
193## Development
194
195### Desktop Gallery (Story)
196
197The `story` crate is a gallery application that showcases all available components. Run it with:
198
199```bash
200cargo run
201```
202
203### Examples
204
205Some larger examples reuse the `story` gallery components and run as standalone packages:
206
207```bash
208# Dock layout system (panels, split views, tabs)
209cargo run -p example-dock
210
211# Markdown rendering
212cargo run -p example-markdown
213
214# HTML rendering
215cargo run -p example-html
216```
217
218The `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>`:
219
220```bash
221# Code editor with LSP support and syntax highlighting
222cargo run -p example-editor
223
224# Basic hello world
225cargo run -p hello_world
226
227# System monitor (real-time charts with CPU/memory data)
228cargo run -p system_monitor
229
230# Window title customization
231cargo run -p window_title
232```
233
234Check out [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
235
236## Compare to others
237
238See the [comparison with Iced, egui and Qt 6](https://gpui-kit.com/docs/comparison) on the site.
239
240## License
241
242Software source and documentation code examples: [Apache-2.0](LICENSE-APACHE).
243
244Documentation prose and original illustrations in the Docs, Base, Component, and Shell sections (including Chinese translations) for which GPUI Kit holds licensing rights are also offered under [CC BY 4.0](LICENSE-DOCS.md). When copying or adapting that material, credit **GPUI Kit**, link to the source page and [CC BY 4.0 license](https://creativecommons.org/licenses/by/4.0/), and indicate changes. Existing Apache-2.0 permissions remain; earlier revisions retain their prior terms, and third-party contributions keep their own licenses unless separately authorized. Using facts or ideas without copying protected expression does not require attribution under CC BY 4.0.
245
246- Built on [GPUI](https://github.com/zed-industries/zed), the UI framework from Zed Industries, also Apache-2.0. The `gpui-pre-*` crates are snapshots of it, published with Zed's license and notices intact.
247- UI design based on [shadcn/ui](https://ui.shadcn.com), some from [Reui](https://reui.io).
248- Icons from [Lucide](https://lucide.dev).