rui provides UI components for building fantastic desktop applications using GPUI.
- SwiftUI-style Syntax: Declarative component composition with macros like
Row!{},Col!{}, andSection!{}. - Rich Components: Buttons, inputs, dialogs, tooltips, avatars, and more.
- Theme Support: Customizable themes with built-in color palettes.
- Easy to Use: Simple API design inspired by modern UI frameworks.
- Cross-platform: Runs on macOS, Windows, and Linux via GPUI.
Add the following to your Cargo.toml:
[dependencies]
gpui = { git = "https://github.com/zed-industries/zed" }
rui = { git = "https://github.com/sandhope/rui.git" }use gpui::*;
use rui::prelude::*;
fn main() {
Application::new().run(|cx: &mut App| {
cx.open_window(WindowOptions::default(), |_, cx| {
cx.new(|_| {
Root! {
Section! {
"Hello Rui";
Text::new("Welcome to Rui!")
Button::new("Click me")
.on_click(|_, _, _| println!("Button clicked!"))
}
}
})
})
.unwrap();
});
}Row/Col: Horizontal and vertical layout containers (macro-based).Root: Root container macro for window content.Section: Sectioned layout with optional title (macro-based).
Text: Text display component.Label: Combined text and icon label.Icon: SVG icon component.Avatar: User avatar with customizable styles.Card: Bordered card container.Divider: Horizontal or vertical separator.Headline: Heading text for section titles.Indicator: Status indicator element.Scrollbar: Customizable scrollbar.
Button/ButtonGroup: Clickable buttons and button groups.Switch: Toggle switch.Checkbox/CheckboxGroup: Checkbox selection.Radio/RadioGroup: Radio button selection.Link: Hyperlink component.Modal/AlertModal: Modal dialogs and alerts.Toast: Temporary notification messages.Tooltip: Hover tooltip.
Input: Text input fieldSlider: Range selectorMenu: Dropdown menuTable: Data tableTheme: Theme systemNotification: Notification center
More components are actively under development!
Rui introduces a declarative syntax similar to SwiftUI, making component composition cleaner:
// Traditional GPUI style
div()
.flex()
.child(Text::new("Hello"))
.child(Button::new("Click"))
// Rui's SwiftUI-style
Row! {
Text::new("Hello")
Button::new("Click")
}The story crate showcases all available components:
cargo run# Tiles example
cargo run --example tilesMore examples can be found in the examples directory.
See DEVELOPMENT for more details.
For detailed API documentation, check out the source code in crates/rui/src/components/.
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
GPL-3.0-or-later