gpui

A fast, productive UI framework for Rust from the creators ofย Zed.

Hello, World ๐ŸŒŽ

use gpui::*;
 
struct HelloWorld {
    text: SharedString,
}
 
impl Render for HelloWorld {
    fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
        div()
            .flex()
            .bg(rgb(0x2e7d32))
            .size_full()
            .justify_center()
            .items_center()
            .text_xl()
            .text_color(rgb(0xffffff))
            .child(format!("Hello, {}!", &self.text))
    }
}
 
fn main() {
    App::new().run(|cx: &mut AppContext| {
        cx.open_window(WindowOptions::default(), |cx| {
            cx.new_view(|_cx| HelloWorld {
                text: "World".into(),
            })
        })
        .unwrap();
    });
}

Today, it's Zed's UI framework. Tomorrow, it's yours!

We'd love your help making that happen.

Docs

gpui โ€“ READMEIntro to gpui (gpui's README)
gpui โ€“ gpui.rsCore functionality and API of gpui (gpui's crate root)
ContextsExplanation of different contexts in gpui
Key DispatchDetails on key event dispatching in gpui

Further docs & examples can be found throughout Zed's crates, and in Zed's ui crate.

Examples

Hello WorldThe basic "Hello, World!" example
AnimationRotating SVG animation
GIF ViewerGIF image in a window
ImageLoading and displaying images
InputBasic text input field
OpacityChanging opacity with animations
Set MenusApplication menus creation and usage
ShadowElement with shadow
SVGSVG images with different colors
Text WrapperText wrapping techniques
Uniform ListOptimized scrollable list using uniform heights
Window PositioningWindow positioning techniques
Window ShadowCustom window shadows and resizing
WindowWindow types and operations

gpui is made possible by

as-ciimaxbrunsfeldmikayla-makimaxdeviantnathansoboConradIrwinSomeoneToIgnoreiamnbutlerosiewiczJosephTLyonsForLoveOfCatsKethkumrnuggetKCaverlybennetboslightknackJunkuiZhangnotpeterrenovate[bot]petrosrgbkrkkvarkdanilo-lealapricotbucket28huacnleeCharlesChen0823sonufrienkoalyginweartistvitallium
How to contribute โ†’

Contributing to gpui

gpui is an open source project. We welcome contributions, but for the near future gpui is tied to Zed, so contributions will need to be made there and kept in sync with it.