gpui-ui-kit
A reusable UI component library for GPUI applications.
Provides composable, styled UI components with consistent theming for building desktop applications with the GPUI framework.
Installation
Add to your Cargo.toml:
[]
= { = "../gpui-ui-kit" }
Components
Core Components
| Component | Description |
|---|---|
Button |
Styled button with variants (Primary, Secondary, Destructive, Ghost, Outline) |
IconButton |
Icon-only button with hover states |
Card |
Container with optional header, content, and footer sections |
Dialog |
Modal dialog with backdrop, title, and customizable size |
Menu / MenuBar |
Navigation menus and menu bars |
Tabs |
Tabbed navigation with Underline, Enclosed, and Pills variants |
Toast / ToastContainer |
Notification toasts with positioning |
Form Components
| Component | Description |
|---|---|
Input |
Text input with label, placeholder, validation, and variants |
Checkbox |
Checkbox with label and indeterminate state |
Toggle |
Toggle switch |
Select |
Dropdown select with options |
Data Display
| Component | Description |
|---|---|
Badge / BadgeDot |
Status badges with variants |
Progress / CircularProgress |
Progress bars and circular indicators |
Spinner / LoadingDots |
Loading indicators |
Avatar / AvatarGroup |
User avatars with status indicators |
Text / Heading / Code / Link |
Typography components |
Feedback
| Component | Description |
|---|---|
Alert / InlineAlert |
Contextual feedback messages (Info, Success, Warning, Error) |
Tooltip |
Hover tooltips with placement options |
Layout
| Component | Description |
|---|---|
VStack / HStack |
Vertical and horizontal stack layouts |
Spacer |
Flexible spacer element |
Divider |
Horizontal/vertical dividers with optional interactivity |
Accordion |
Collapsible content panels |
Breadcrumbs |
Navigation breadcrumbs |
Usage Examples
Button
use ;
// Basic button
new
// Primary button with click handler
new
.variant
.on_click
// Destructive button
new
.variant
.size
// Ghost button with icon
new
.variant
.icon_left
// Full width disabled button
new
.full_width
.disabled
Card
use Card;
use div;
new
.header
.content
.footer
Input
use ;
// Basic input with label
new
.label
.placeholder
// Input with error
new
.label
.value
.error
// Filled variant
new
.variant
.placeholder
.icon_left
Tabs
use ;
new
.tabs
.selected_index
.variant
.on_change
Dialog
use ;
use div;
new
.title
.size
.content
.footer
.on_close
Alert
use ;
// Full alert with title
new
.title
.variant
.closeable
.on_close
// Inline alert
new
.variant
Stack Layouts
use ;
// Vertical stack
new
.spacing
.align
.child
.child
.child
.child
// Horizontal stack with divider
new
.spacing
.child
.child
.child
Progress
use ;
// Linear progress bar
new
.variant
.size
.show_label
// Circular progress
new
.size
.variant
.show_label
Checkbox and Toggle
use ;
// Checkbox with label
new
.label
.checked
.on_change
// Toggle switch
new
.label
.checked
.size
Select
use ;
new
.label
.placeholder
.options
.selected
.on_change
Avatar
use ;
// Single avatar with status
new
.initials
.size
.status
// Avatar group
new
.avatars
.max_visible
Tooltip
use ;
// Wrap any element with a tooltip
new
Accordion
use ;
use div;
new
.mode
.items
Theming
Components use a default dark theme. Button theme can be customized:
use ;
use rgb;
let custom_theme = ButtonTheme ;
new
.theme
Design Patterns
Builder Pattern
All components use the builder pattern for configuration:
new
.optional_setting
.another_setting
// Either render directly or build for additional handlers
Event Handlers
Components that support interaction accept closures:
new
.on_click
new
.on_change
Using with GPUI Listeners
For components that need cx.listener(), use the build() method:
new
.build
.on_click
License
See workspace root for license information.