Gpui Layout And Style
CSS-like styling with Rust type safety for GPUI components
✨ The solution you've been looking for
Layout and styling in GPUI. Use when styling components, layout systems, or CSS-like properties.
See It In Action
Interactive preview & real-world examples
AI Conversation Simulator
See how users interact with this skill
User Prompt
Help me style a button component with rounded corners, padding, and hover effects in GPUI
Skill Processing
Analyzing request...
Agent Response
Complete GPUI styling code with proper method chaining, dimensions, colors, and interactive states
Quick Start (3 Steps)
Get up and running in minutes
Install
claude-code skill install gpui-layout-and-style
claude-code skill install gpui-layout-and-styleConfig
First Trigger
@gpui-layout-and-style helpCommands
| Command | Description | Required Args |
|---|---|---|
| @gpui-layout-and-style component-styling | Apply modern CSS-like styles to GPUI components with type safety | None |
| @gpui-layout-and-style flexbox-layouts | Create responsive layouts using GPUI's flexbox system | None |
| @gpui-layout-and-style theme-integration | Integrate with GPUI's theming system for consistent styling | None |
Typical Use Cases
Component Styling
Apply modern CSS-like styles to GPUI components with type safety
Flexbox Layouts
Create responsive layouts using GPUI's flexbox system
Theme Integration
Integrate with GPUI's theming system for consistent styling
Overview
Overview
GPUI provides CSS-like styling with Rust type safety.
Key Concepts:
- Flexbox layout system
- Styled trait for chaining styles
- Size units:
px(),rems(),relative() - Colors, borders, shadows
Quick Start
Basic Styling
1use gpui::*;
2
3div()
4 .w(px(200.))
5 .h(px(100.))
6 .bg(rgb(0x2196F3))
7 .text_color(rgb(0xFFFFFF))
8 .rounded(px(8.))
9 .p(px(16.))
10 .child("Styled content")
Flexbox Layout
1div()
2 .flex()
3 .flex_row() // or flex_col() for column
4 .gap(px(8.))
5 .items_center()
6 .justify_between()
7 .children([
8 div().child("Item 1"),
9 div().child("Item 2"),
10 div().child("Item 3"),
11 ])
Size Units
1div()
2 .w(px(200.)) // Pixels
3 .h(rems(10.)) // Relative to font size
4 .w(relative(0.5)) // 50% of parent
5 .min_w(px(100.))
6 .max_w(px(400.))
Common Patterns
Centered Content
1div()
2 .flex()
3 .items_center()
4 .justify_center()
5 .size_full()
6 .child("Centered")
Card Layout
1div()
2 .w(px(300.))
3 .bg(cx.theme().surface)
4 .rounded(px(8.))
5 .shadow_md()
6 .p(px(16.))
7 .gap(px(12.))
8 .flex()
9 .flex_col()
10 .child(heading())
11 .child(content())
Responsive Spacing
1div()
2 .p(px(16.)) // Padding all sides
3 .px(px(20.)) // Padding horizontal
4 .py(px(12.)) // Padding vertical
5 .pt(px(8.)) // Padding top
6 .gap(px(8.)) // Gap between children
Styling Methods
Dimensions
1.w(px(200.)) // Width
2.h(px(100.)) // Height
3.size(px(200.)) // Width and height
4.min_w(px(100.)) // Min width
5.max_w(px(400.)) // Max width
Colors
1.bg(rgb(0x2196F3)) // Background
2.text_color(rgb(0xFFFFFF)) // Text color
3.border_color(rgb(0x000000)) // Border color
Borders
1.border(px(1.)) // Border width
2.rounded(px(8.)) // Border radius
3.rounded_t(px(8.)) // Top corners
4.border_color(rgb(0x000000))
Spacing
1.p(px(16.)) // Padding
2.m(px(8.)) // Margin
3.gap(px(8.)) // Gap between flex children
Flexbox
1.flex() // Enable flexbox
2.flex_row() // Row direction
3.flex_col() // Column direction
4.items_center() // Align items center
5.justify_between() // Space between items
6.flex_grow() // Grow to fill space
Theme Integration
1div()
2 .bg(cx.theme().surface)
3 .text_color(cx.theme().foreground)
4 .border_color(cx.theme().border)
5 .when(is_hovered, |el| {
6 el.bg(cx.theme().hover)
7 })
Conditional Styling
1div()
2 .when(is_active, |el| {
3 el.bg(cx.theme().primary)
4 })
5 .when_some(optional_color, |el, color| {
6 el.bg(color)
7 })
Reference Documentation
- Complete Guide: See reference.md
- All styling methods
- Layout strategies
- Theming, responsive design
What Users Are Saying
Real feedback from the community
Environment Matrix
Dependencies
Framework Support
Context Window
Security & Privacy
Information
- Author
- longbridge
- Updated
- 2026-01-30
- Category
- frontend
Related Skills
Gpui Layout And Style
Layout and styling in GPUI. Use when styling components, layout systems, or CSS-like properties.
View Details →Generate Component Story
Create story examples for components. Use when writing stories, creating examples, or demonstrating …
View Details →Generate Component Story
Create story examples for components. Use when writing stories, creating examples, or demonstrating …
View Details →