Loading...
Loading...
gpui-component library patterns for building reusable UI components. Use when creating buttons, inputs, dialogs, forms, or following Longbridge component library conventions in GPUI applications.
npx skill4agent add aprilnea/gpui-skills gpui-component| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Component Architecture | CRITICAL | |
| 2 | Trait System | CRITICAL | |
| 3 | Theme System | HIGH | |
| 4 | Dialog & Popover | HIGH | |
| 5 | Form Components | MEDIUM | |
| 6 | Animation | MEDIUM | |
comp-renderoncecomp-structurecomp-buildercomp-statefulcomp-callbackstrait-styledtrait-disableabletrait-selectabletrait-sizabletrait-parent-elementtrait-interactivetheme-colorstheme-activetheme-variantstheme-size-systemdialog-rootdialog-window-extdialog-confirmdialog-formpopover-patternform-input-stateform-focusform-validationanim-with-animationanim-keyed-stateanim-easing#[derive(IntoElement)]
pub struct MyComponent {
// 1. Identifier
id: ElementId,
// 2. Base element (for event delegation)
base: Div,
// 3. Style override
style: StyleRefinement,
// 4. Content
label: Option<SharedString>,
children: Vec<AnyElement>,
// 5. State configuration
disabled: bool,
selected: bool,
size: Size,
// 6. Callbacks
on_click: Option<Rc<dyn Fn(&ClickEvent, &mut Window, &mut App)>>,
}┌─────────────────────────────────────────────────────────────┐
│ Window │
│ ├── Root (Entity, manages overlay state) │
│ │ ├── view: AnyView (user's main view) │
│ │ ├── active_dialogs: Vec<ActiveDialog> │
│ │ ├── active_sheet: Option<ActiveSheet> │
│ │ └── notification: Entity<NotificationList> │
│ │ │
│ └── Render Layers │
│ ├── Layer 0: Root.view (main content) │
│ ├── Layer 1: Sheet (side drawer) │
│ ├── Layer 2: Dialogs (stackable) │
│ └── Layer 3: Notifications │
└─────────────────────────────────────────────────────────────┘| Feature | Dialog | Popover | PopupMenu | Sheet |
|---|---|---|---|---|
| Position | Centered | Anchored | Anchored | Side |
| Overlay | Yes | No | No | Yes |
| State | Root | keyed_state | Entity | Root |
| Stacking | Multiple | Single | Submenus | Single |
| Close | ESC/Click/Button | ESC/Outside | ESC/Select | ESC/Overlay |
rules/comp-renderonce.md
rules/trait-styled.md
rules/dialog-root.md