gpui-layout-and-style by longbridge/gpui-component
npx skills add https://github.com/longbridge/gpui-component --skill gpui-layout-and-styleGPUI 提供了类似 CSS 的样式功能,并具备 Rust 的类型安全性。
核心概念:
Styled traitpx()、rems()、relative()use gpui::*;
div()
.w(px(200.))
.h(px(100.))
.bg(rgb(0x2196F3))
.text_color(rgb(0xFFFFFF))
.rounded(px(8.))
.p(px(16.))
.child("Styled content")
div()
.flex()
.flex_row() // 或使用 flex_col() 表示列布局
.gap(px(8.))
.items_center()
.justify_between()
.children([
div().child("Item 1"),
div().child("Item 2"),
div().child("Item 3"),
])
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
div()
.w(px(200.)) // 像素
.h(rems(10.)) // 相对于字体大小
.w(relative(0.5)) // 父元素的 50%
.min_w(px(100.))
.max_w(px(400.))
div()
.flex()
.items_center()
.justify_center()
.size_full()
.child("Centered")
div()
.w(px(300.))
.bg(cx.theme().surface)
.rounded(px(8.))
.shadow_md()
.p(px(16.))
.gap(px(12.))
.flex()
.flex_col()
.child(heading())
.child(content())
div()
.p(px(16.)) // 所有边距的内边距
.px(px(20.)) // 水平方向内边距
.py(px(12.)) // 垂直方向内边距
.pt(px(8.)) // 顶部内边距
.gap(px(8.)) // 子元素之间的间隔
.w(px(200.)) // 宽度
.h(px(100.)) // 高度
.size(px(200.)) // 宽度和高度
.min_w(px(100.)) // 最小宽度
.max_w(px(400.)) // 最大宽度
.bg(rgb(0x2196F3)) // 背景色
.text_color(rgb(0xFFFFFF)) // 文字颜色
.border_color(rgb(0x000000)) // 边框颜色
.border(px(1.)) // 边框宽度
.rounded(px(8.)) // 边框圆角
.rounded_t(px(8.)) // 顶部圆角
.border_color(rgb(0x000000))
.p(px(16.)) // 内边距
.m(px(8.)) // 外边距
.gap(px(8.)) // Flex 子元素之间的间隔
.flex() // 启用 flexbox
.flex_row() // 行方向
.flex_col() // 列方向
.items_center() // 项目居中对齐
.justify_between() // 项目两端对齐
.flex_grow() // 扩展以填充空间
div()
.bg(cx.theme().surface)
.text_color(cx.theme().foreground)
.border_color(cx.theme().border)
.when(is_hovered, |el| {
el.bg(cx.theme().hover)
})
div()
.when(is_active, |el| {
el.bg(cx.theme().primary)
})
.when_some(optional_color, |el, color| {
el.bg(color)
})
每周安装量
163
代码仓库
GitHub 星标数
10.8K
首次出现
2026年1月21日
安全审计
安装于
opencode148
codex140
gemini-cli138
github-copilot129
amp119
cursor119
GPUI provides CSS-like styling with Rust type safety.
Key Concepts:
px(), rems(), relative()use gpui::*;
div()
.w(px(200.))
.h(px(100.))
.bg(rgb(0x2196F3))
.text_color(rgb(0xFFFFFF))
.rounded(px(8.))
.p(px(16.))
.child("Styled content")
div()
.flex()
.flex_row() // or flex_col() for column
.gap(px(8.))
.items_center()
.justify_between()
.children([
div().child("Item 1"),
div().child("Item 2"),
div().child("Item 3"),
])
div()
.w(px(200.)) // Pixels
.h(rems(10.)) // Relative to font size
.w(relative(0.5)) // 50% of parent
.min_w(px(100.))
.max_w(px(400.))
div()
.flex()
.items_center()
.justify_center()
.size_full()
.child("Centered")
div()
.w(px(300.))
.bg(cx.theme().surface)
.rounded(px(8.))
.shadow_md()
.p(px(16.))
.gap(px(12.))
.flex()
.flex_col()
.child(heading())
.child(content())
div()
.p(px(16.)) // Padding all sides
.px(px(20.)) // Padding horizontal
.py(px(12.)) // Padding vertical
.pt(px(8.)) // Padding top
.gap(px(8.)) // Gap between children
.w(px(200.)) // Width
.h(px(100.)) // Height
.size(px(200.)) // Width and height
.min_w(px(100.)) // Min width
.max_w(px(400.)) // Max width
.bg(rgb(0x2196F3)) // Background
.text_color(rgb(0xFFFFFF)) // Text color
.border_color(rgb(0x000000)) // Border color
.border(px(1.)) // Border width
.rounded(px(8.)) // Border radius
.rounded_t(px(8.)) // Top corners
.border_color(rgb(0x000000))
.p(px(16.)) // Padding
.m(px(8.)) // Margin
.gap(px(8.)) // Gap between flex children
.flex() // Enable flexbox
.flex_row() // Row direction
.flex_col() // Column direction
.items_center() // Align items center
.justify_between() // Space between items
.flex_grow() // Grow to fill space
div()
.bg(cx.theme().surface)
.text_color(cx.theme().foreground)
.border_color(cx.theme().border)
.when(is_hovered, |el| {
el.bg(cx.theme().hover)
})
div()
.when(is_active, |el| {
el.bg(cx.theme().primary)
})
.when_some(optional_color, |el, color| {
el.bg(color)
})
Weekly Installs
163
Repository
GitHub Stars
10.8K
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode148
codex140
gemini-cli138
github-copilot129
amp119
cursor119
Rust性能优化指南:m10-performance技能详解,包含算法、数据结构与内存优化策略
713 周安装