Read This First
Before changing UI, interaction, interface language, layout, styling,
components, or application architecture, read the relevant guide:
| Guide |
Read before |
| Design Guides |
Choosing components, layout, spacing, hierarchy, color, density, interaction states, overlays, interface copy |
| Coding Guides |
Crate layering, RenderOnce vs Entity<T>, state ownership, ElementId, focus, async, public API, testing |
These guides are requirements, not optional inspiration. Do not copy generic
web conventions, infer a design system from one existing screen, or add a
control merely because the underlying feature exists. Review the finished work
against both guides before considering it complete.
Read the guide file itself. Do not answer from what this page summarizes, from
an existing screen in the codebase, or from training data — those are the three
ways the guides get quietly ignored.
Non-negotiables
These are a floor, not a substitute. Read the guide for anything past this list.
- Never invent an API. Search the current source for the real signature.
Do not translate a React, CSS, or older-GPUI example by analogy — a
plausible-looking method name that does not exist is the most common
failure mode here.
- Desktop before web convention. Keyboard access, window chrome, menus,
dense data views, resizable regions, persistent navigation.
Button vs Link. Button for every in-app command — use ghost or
outline when it should read quietly. Link only for external URLs and
email addresses.
- Tokens before values. No raw hex or
rgb(...) in application UI; use
cx.theme() semantic tokens. Use rem-based helpers (p_2(), gap_3(),
text_sm()) so window zoom works. Any spacing number you see quoted is the
current default scale, not a literal to repeat.
- State must be visible. Hover, focus, selection, disabled, loading,
validation, and destructive states each need distinct, consistent treatment.
- Stable identity. Repeated elements need domain-derived
ElementIds, not
list indexes.
- Overlays. Escape dismisses the topmost surface and returns focus to its
trigger.
- Copy. Name the object and the verb —
Delete “Roadmap”? with a Delete
button, not Are you sure? with OK.
Documentation
- Full reference: fetch
https://longbridge.github.io/gpui-component/llms-full.txt
- Per-component API: fetch
https://longbridge.github.io/gpui-component/docs/components/{name}.md
- e.g.
button.md, input.md, select.md, dialog.md, data-table.md
- Any site page can be fetched as Markdown by appending
.md to the URL
Quick Reference
Setup — always required:
gpui_component::init(cx); // in app.run(), must be first
Root::new(view, window, cx) // first-level view in every window
Stateless — use directly in render:
Button::new("id").primary().label("OK").on_click(|_, _, _| {})
Stateful — hold Entity<State> in struct, pass ref in render:
// in new(): let input = cx.new(|cx| InputState::new(window, cx));
// in render: Input::new(&self.input)
Sizes: .xsmall() .small() .medium() (default) .large()
Theme: cx.theme().primary · .background · .foreground · .border · .muted
Component Catalog
When you need a component, find it here. For full API, fetch its .md doc.
Input & Form
| Component |
Import |
Notes |
Input |
input::{Input, InputState} |
Stateful. Text, password, mask, validation |
NumberInput |
input::{NumberInput, NumberInputEvent} |
Stateful. Numeric with step |
OtpInput |
input::OtpInput |
Stateful. One-time password |
Select |
select::{Select, SelectState} |
Stateful. Dropdown picker |
Combobox |
combobox::{Combobox, ComboboxState} |
Stateful. Searchable select |
Checkbox |
checkbox::Checkbox |
Stateless. `on_click( |
Switch |
switch::Switch |
Stateless. Toggle |
Radio |
radio::{Radio, RadioGroup} |
Stateless. |
Slider |
slider::{Slider, SliderState} |
Stateful. |
Toggle |
button::Toggle |
Stateless. |
Rating |
rating::Rating |
Stateless. |
Stepper |
stepper::Stepper |
Stateless. Increment/decrement |
ColorPicker |
color_picker::{ColorPicker, ColorPickerState} |
Stateful. |
DatePicker |
date_picker::{DatePicker, DatePickerState} |
Stateful. |
Form |
form::{v_form, h_form, field} |
Layout container for form fields |
Display & Feedback
| Component |
Import |
Notes |
Button |
button::{Button, ButtonGroup} |
Stateless. Primary UI action |
Icon |
{Icon, IconName} |
Stateless. Lucide icons |
Badge |
badge::Badge |
Stateless. |
Tag |
tag::Tag |
Stateless. Closable tags |
Avatar |
avatar::Avatar |
Stateless. |
Label |
label::Label |
Stateless. Form label |
Kbd |
kbd::Kbd |
Stateless. Keyboard key display |
Alert |
alert::Alert |
Stateless. Info/success/warning/error |
Spinner |
spinner::Spinner |
Stateless. Loading indicator |
Skeleton |
skeleton::Skeleton |
Stateless. Loading placeholder |
Progress |
progress::{Progress, ProgressCircle} |
Stateless. |
Tooltip |
tooltip::Tooltip |
Via .tooltip() on elements |
HoverCard |
hover_card::{HoverCard, HoverCardState} |
Stateful. |
Clipboard |
clipboard::Clipboard |
Stateless. Copy button |
Overlay & Popups
| Component |
Import |
Notes |
Dialog |
dialog::Dialog + WindowExt |
Via window.open_dialog(...) |
AlertDialog |
WindowExt |
Via window.open_alert_dialog(...) |
Sheet |
sheet::Sheet + WindowExt |
Side panel, via window.open_sheet(...) |
Notification |
notification::Notification + WindowExt |
Via window.push_notification(...) |
Popover |
popover::Popover |
Floating overlay |
Menu |
menu::{PopupMenu, DropdownMenu} |
Context menus |
DropdownButton |
button::DropdownButton |
Button with dropdown menu |
Navigation & Layout
| Component |
Import |
Notes |
Tabs / TabBar |
tab::{Tab, TabBar} |
Tabbed interface |
Sidebar |
sidebar::{Sidebar, SidebarMenu, ...} |
App navigation panel |
TitleBar |
TitleBar |
Window title bar |
Breadcrumb |
breadcrumb::Breadcrumb |
Navigation breadcrumb |
Pagination |
pagination::Pagination |
Page navigation |
Accordion |
accordion::Accordion |
Collapsible sections |
Collapsible |
collapsible::Collapsible |
Single collapsible |
GroupBox |
group_box::GroupBox |
Labeled container |
Resizable |
resizable::{h_resizable, v_resizable, resizable_panel, ResizableState} |
Draggable split panes |
Scrollable |
scroll::Scrollbar |
Custom scrollbar |
FocusTrap |
gpui_base::focus_trap::FocusTrapElement |
Keyboard trap for modals |
Data Display
| Component |
Import |
Notes |
DataTable |
table::{DataTable, TableState, TableDelegate} |
Stateful. Full-featured table |
Table |
table::{Table, ...} |
Simpler table |
VirtualList |
{v_virtual_list, h_virtual_list} |
High-perf large lists |
List |
list::{List, ListState, ListDelegate} |
Stateful. Searchable list |
Tree |
tree::{Tree, TreeState, TreeItem, TreeEntry} |
Stateful. Hierarchy |
DescriptionList |
description_list::DescriptionList |
Key-value pairs |
Settings |
setting::Settings |
Settings panel |
Charts
| Component |
Import |
Notes |
Chart |
chart::{AreaChart, BarChart, LineChart, PieChart, RadarChart} |
Bar, line, area, pie charts |
Plot |
plot::Plot |
#[derive(IntoPlot)] for data |
Reference Files
- usage.md — setup patterns, component types, common examples
- style-guide.md — code style for contributors
1---2name: gpui-component3description: How to use the gpui-component UI library in GPUI applications, and the normative Design and Coding Guides that govern it. Use when building UIs with gpui-component components (Button, Input, Select, Dialog, Tabs, Sidebar, List, Table, etc.), setting up the library, handling component state or theming, finding the right component for a UI need, and also when designing layouts, spacing, visual hierarchy, or interaction states, writing interface copy, or making application architecture, state-ownership, or public API decisions.4---56## Read This First78Before changing UI, interaction, interface language, layout, styling,9components, or application architecture, **read the relevant guide**:1011| Guide | Read before |12| --- | --- |13| [Design Guides](references/design-guides.md) | Choosing components, layout, spacing, hierarchy, color, density, interaction states, overlays, interface copy |14| [Coding Guides](references/coding-guides.md) | Crate layering, `RenderOnce` vs `Entity<T>`, state ownership, `ElementId`, focus, async, public API, testing |1516These guides are requirements, not optional inspiration. Do not copy generic17web conventions, infer a design system from one existing screen, or add a18control merely because the underlying feature exists. Review the finished work19against both guides before considering it complete.2021Read the guide file itself. Do not answer from what this page summarizes, from22an existing screen in the codebase, or from training data — those are the three23ways the guides get quietly ignored.2425### Non-negotiables2627These are a floor, not a substitute. Read the guide for anything past this list.2829- **Never invent an API.** Search the current source for the real signature.30 Do not translate a React, CSS, or older-GPUI example by analogy — a31 plausible-looking method name that does not exist is the most common32 failure mode here.33- **Desktop before web convention.** Keyboard access, window chrome, menus,34 dense data views, resizable regions, persistent navigation.35- **`Button` vs `Link`.** `Button` for every in-app command — use `ghost` or36 `outline` when it should read quietly. `Link` only for external URLs and37 email addresses.38- **Tokens before values.** No raw hex or `rgb(...)` in application UI; use39 `cx.theme()` semantic tokens. Use rem-based helpers (`p_2()`, `gap_3()`,40 `text_sm()`) so window zoom works. Any spacing number you see quoted is the41 current default scale, not a literal to repeat.42- **State must be visible.** Hover, focus, selection, disabled, loading,43 validation, and destructive states each need distinct, consistent treatment.44- **Stable identity.** Repeated elements need domain-derived `ElementId`s, not45 list indexes.46- **Overlays.** Escape dismisses the topmost surface and returns focus to its47 trigger.48- **Copy.** Name the object and the verb — `Delete “Roadmap”?` with a `Delete`49 button, not `Are you sure?` with `OK`.5051## Documentation5253- **Full reference**: fetch `https://longbridge.github.io/gpui-component/llms-full.txt`54- **Per-component API**: fetch `https://longbridge.github.io/gpui-component/docs/components/{name}.md`55 - e.g. `button.md`, `input.md`, `select.md`, `dialog.md`, `data-table.md`56- **Any site page** can be fetched as Markdown by appending `.md` to the URL5758## Quick Reference5960**Setup** — always required:61```rust62gpui_component::init(cx); // in app.run(), must be first63Root::new(view, window, cx) // first-level view in every window64```6566**Stateless** — use directly in render:67```rust68Button::new("id").primary().label("OK").on_click(|_, _, _| {})69```7071**Stateful** — hold `Entity<State>` in struct, pass ref in render:72```rust73// in new(): let input = cx.new(|cx| InputState::new(window, cx));74// in render: Input::new(&self.input)75```7677**Sizes**: `.xsmall()` `.small()` `.medium()` (default) `.large()`7879**Theme**: `cx.theme().primary` · `.background` · `.foreground` · `.border` · `.muted`8081## Component Catalog8283When you need a component, find it here. For full API, fetch its `.md` doc.8485### Input & Form86| Component | Import | Notes |87|-----------|--------|-------|88| `Input` | `input::{Input, InputState}` | Stateful. Text, password, mask, validation |89| `NumberInput` | `input::{NumberInput, NumberInputEvent}` | Stateful. Numeric with step |90| `OtpInput` | `input::OtpInput` | Stateful. One-time password |91| `Select` | `select::{Select, SelectState}` | Stateful. Dropdown picker |92| `Combobox` | `combobox::{Combobox, ComboboxState}` | Stateful. Searchable select |93| `Checkbox` | `checkbox::Checkbox` | Stateless. `on_click(|&bool, ...|)` |94| `Switch` | `switch::Switch` | Stateless. Toggle |95| `Radio` | `radio::{Radio, RadioGroup}` | Stateless. |96| `Slider` | `slider::{Slider, SliderState}` | Stateful. |97| `Toggle` | `button::Toggle` | Stateless. |98| `Rating` | `rating::Rating` | Stateless. |99| `Stepper` | `stepper::Stepper` | Stateless. Increment/decrement |100| `ColorPicker` | `color_picker::{ColorPicker, ColorPickerState}` | Stateful. |101| `DatePicker` | `date_picker::{DatePicker, DatePickerState}` | Stateful. |102| `Form` | `form::{v_form, h_form, field}` | Layout container for form fields |103104### Display & Feedback105| Component | Import | Notes |106|-----------|--------|-------|107| `Button` | `button::{Button, ButtonGroup}` | Stateless. Primary UI action |108| `Icon` | `{Icon, IconName}` | Stateless. Lucide icons |109| `Badge` | `badge::Badge` | Stateless. |110| `Tag` | `tag::Tag` | Stateless. Closable tags |111| `Avatar` | `avatar::Avatar` | Stateless. |112| `Label` | `label::Label` | Stateless. Form label |113| `Kbd` | `kbd::Kbd` | Stateless. Keyboard key display |114| `Alert` | `alert::Alert` | Stateless. Info/success/warning/error |115| `Spinner` | `spinner::Spinner` | Stateless. Loading indicator |116| `Skeleton` | `skeleton::Skeleton` | Stateless. Loading placeholder |117| `Progress` | `progress::{Progress, ProgressCircle}` | Stateless. |118| `Tooltip` | `tooltip::Tooltip` | Via `.tooltip()` on elements |119| `HoverCard` | `hover_card::{HoverCard, HoverCardState}` | Stateful. |120| `Clipboard` | `clipboard::Clipboard` | Stateless. Copy button |121122### Overlay & Popups123| Component | Import | Notes |124|-----------|--------|-------|125| `Dialog` | `dialog::Dialog` + `WindowExt` | Via `window.open_dialog(...)` |126| `AlertDialog` | `WindowExt` | Via `window.open_alert_dialog(...)` |127| `Sheet` | `sheet::Sheet` + `WindowExt` | Side panel, via `window.open_sheet(...)` |128| `Notification` | `notification::Notification` + `WindowExt` | Via `window.push_notification(...)` |129| `Popover` | `popover::Popover` | Floating overlay |130| `Menu` | `menu::{PopupMenu, DropdownMenu}` | Context menus |131| `DropdownButton` | `button::DropdownButton` | Button with dropdown menu |132133### Navigation & Layout134| Component | Import | Notes |135|-----------|--------|-------|136| `Tabs` / `TabBar` | `tab::{Tab, TabBar}` | Tabbed interface |137| `Sidebar` | `sidebar::{Sidebar, SidebarMenu, ...}` | App navigation panel |138| `TitleBar` | `TitleBar` | Window title bar |139| `Breadcrumb` | `breadcrumb::Breadcrumb` | Navigation breadcrumb |140| `Pagination` | `pagination::Pagination` | Page navigation |141| `Accordion` | `accordion::Accordion` | Collapsible sections |142| `Collapsible` | `collapsible::Collapsible` | Single collapsible |143| `GroupBox` | `group_box::GroupBox` | Labeled container |144| `Resizable` | `resizable::{h_resizable, v_resizable, resizable_panel, ResizableState}` | Draggable split panes |145| `Scrollable` | `scroll::Scrollbar` | Custom scrollbar |146| `FocusTrap` | `gpui_base::focus_trap::FocusTrapElement` | Keyboard trap for modals |147148### Data Display149| Component | Import | Notes |150|-----------|--------|-------|151| `DataTable` | `table::{DataTable, TableState, TableDelegate}` | Stateful. Full-featured table |152| `Table` | `table::{Table, ...}` | Simpler table |153| `VirtualList` | `{v_virtual_list, h_virtual_list}` | High-perf large lists |154| `List` | `list::{List, ListState, ListDelegate}` | Stateful. Searchable list |155| `Tree` | `tree::{Tree, TreeState, TreeItem, TreeEntry}` | Stateful. Hierarchy |156| `DescriptionList` | `description_list::DescriptionList` | Key-value pairs |157| `Settings` | `setting::Settings` | Settings panel |158159### Charts160| Component | Import | Notes |161|-----------|--------|-------|162| `Chart` | `chart::{AreaChart, BarChart, LineChart, PieChart, RadarChart}` | Bar, line, area, pie charts |163| `Plot` | `plot::Plot` | `#[derive(IntoPlot)]` for data |164165## Reference Files166167- [usage.md](references/usage.md) — setup patterns, component types, common examples168- [style-guide.md](references/style-guide.md) — code style for contributors