longbridge/gpui-component

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

9.9K stars433 forksUpdated Jan 26, 2026
npx skills add longbridge/gpui-component

README

GPUI Component

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 (support up to 200K lines) with LSP (diagnostics, completion, hover, etc).
  • Syntax Highlighting: Syntax highlighting for editor and markdown components using Tree Sitter.

Showcase

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

Image

Usage

gpui = "0.2.2"
gpui-component = "0.5.0"

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

            Ok::<_, anyhow::Error>(())
        })
        .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

We have a gallery of applications built with GPUI Component.

cargo run

More examples can be found in the examples directory. You can run them with cargo run --example <example_name>.

Check out CONTRIBUTING.md for more details.

Compare to others

FeaturesGPUI Component[Iced][egui][Qt 6]
LanguageRustRustRustC++/QML
Core RenderGPUIwgpuwgpuQT
LicenseApache 2.0MITMIT/Apache 2.0Commercial/LGPL
Min Binary Size [^1]12MB11MB5M20MB [^2]
Cross-PlatformYesYesYesYes
DocumentationSimpleSimpleSimpleGood
WebNoYesYesYes
UI

...

Read full README

Publisher

longbridgelongbridge

Statistics

Stars9.9K
Forks433
Open Issues55
LicenseOther
CreatedJun 13, 2024