Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

GPUI Component

English | 简体中文

Build Status Docs Crates.io

UI components for building fantastic desktop applications using GPUI.

Features

  • Richness: 60+ cross-platform desktop UI components.
  • Native: Inspired by macOS and Windows controls, combined with shadcn/ui design for a modern experience.
  • Ease of Use: Stateless RenderOnce components, simple and user-friendly.
  • Customizable: Built-in Theme and ThemeColor, supporting multi-theme and variable-based configurations.
  • Versatile: Supports sizes like xs, sm, md, and lg.
  • Flexible Layout: Dock layout for panel arrangements, resizing, and freeform (Tiles) layouts.
  • High Performance: Virtualized Table and List components for smooth large-data rendering.
  • Content Rendering: Native support for Markdown and simple HTML.
  • Charting: Built-in charts for visualizing your data.
  • Editor: High performance code editor (Up to 200K lines for stable performance) with LSP (diagnostics, completion, hover, etc).
  • Syntax Highlighting: Syntax highlighting for editor and markdown components using Tree Sitter.

Showcase

https://longbridge.github.io/gpui-component/gallery/

Here is the first application: Longbridge Pro, built using GPUI Component.

Image

Usage

gpui = "0.2.2" gpui-component = "0.5.1"

Basic Example

use gpui::*; use gpui_component::{button::*, *}; 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() { let app = Application::new(); app.run(move |cx| { // This must be called before using any GPUI Component features. gpui_component::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

GPUI Component has an Icon element, but it does not include SVG files by default.

The example uses Lucide icons, but you can use any icons you like. Just name the SVG files as defined in IconName. You can add any icons you need to your project.

Development

Desktop Gallery (Story)

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

cargo run

Examples

Some important examples are built into the story crate and can be run directly:

# Code editor with LSP support and syntax highlighting cargo run --example editor # Dock layout system (panels, split views, tabs) cargo run --example dock # Markdown rendering cargo run --example markdown # HTML rendering cargo run --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>:

# 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

Web Gallery (WASM)

You can also run the gallery in a web browser using WASM:

cd crates/story-web # Install dependencies (first time only) make install # Build and run development server make dev

The gallery will be available at http://localhost:3000

For more details, see crates/story-web/README.md.

Check out CONTRIBUTING.md for more details.

Compare to others

FeaturesGPUI ComponentIcedeguiQt 6
LanguageRustRustRustC++/QML
Core RenderGPUIwgpuwgpuQT
LicenseApache 2.0MITMIT/Apache 2.0Commercial/LGPL
Min Binary Size 112MB11MB5M20MB 2
Cross-PlatformYesYesYesYes
DocumentationSimpleSimpleSimpleGood
WebYes (WASM)YesYesYes
UI StyleModernBasicBasicBasic
CJK SupportYesYesBadYes
ChartYesNoNoYes
Table (Large dataset)Yes
(Virtual Rows, Columns)
NoYes
(Virtual Rows)
Yes
(Virtual Rows, Columns)
Table Column ResizeYesNoYesYes
Text baseRopeCOSMIC Text 3trait TextBuffer 4QTextDocument
CodeEditorSimpleSimpleSimpleBasic API
Dock LayoutYesYesYesYes
Syntax HighlightTree SitterSyntectSyntectQSyntaxHighlighter
Markdown RenderingYesYesBasicNo
Markdown mix HTMLYesNoNoNo
HTML RenderingBasicNoNoBasic
Text SelectionTextViewNoAny LabelYes
Custom ThemeYesYesYesYes
Built ThemesYesNoNoNo
I18nYesYesYesYes

Please submit an issue or PR if any mistakes or outdated are found.

License

Apache-2.0

Footnotes

  1. Release builds by use simple hello world example.

  2. Reducing Binary Size of Qt Applications

  3. Iced Editor: https://github.com/iced-rs/iced/blob/db5a1f6353b9f8520c4f9633d1cdc90242c2afe1/graphics/src/text/editor.rs#L65-L68

  4. egui TextBuffer: https://github.com/emilk/egui/blob/0a81372cfd3a4deda640acdecbbaf24bf78bb6a2/crates/egui/src/widgets/text_edit/text_buffer.rs#L20

关于 About

Rust GUI components for building fantastic cross-platform desktop application by using GPUI.
desktop-applicationgpuirustuikit

语言 Languages

Rust97.7%
Tree-sitter Query0.9%
HTML0.2%
Shell0.2%
JavaScript0.1%
Lua0.1%
Svelte0.1%
Kotlin0.1%
Astro0.1%
Python0.1%
C0.1%
Zig0.1%
Ruby0.1%
Nix0.1%
Go0.1%
PHP0.1%
Makefile0.0%
TypeScript0.0%
PowerShell0.0%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
983
Total Commits
峰值: 47次/周
Less
More

核心贡献者 Contributors