gpui-elements
БесплатноБез исполняемых скриптовНе проверенUI element creation and composition with GPUI. Use when building element trees, creating custom components, implementing layouts, or working with conditional…
Об этом скилле
GPUI Elements
This skill covers creating and composing UI elements in GPUI applications.
Overview
Elements are the building blocks of GPUI UIs:
- Built with
div()as the base element - Styled with chainable methods
- Composed with
.child()and.children() - Support conditional rendering with
.when() - Use flexbox for layout
Basic Element Creation
div() Element
use gpui::*;
impl Render for MyView {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
div()
.child("Hello, GPUI!")
}
}
Adding Children
div()
.child("First child")
.child(
div()
.child("Nested child")
)
.child("Third child")
Multiple Children with Vector
let items = vec!["One", "Two", "Three"];
div().children(
items.into_iter().map(|text| {
div().child(text)
})
)
Text Elements
String Types
use gpui::*;
impl Render for MyView {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
div()
// &str
.child("Static text")
// String
.child(format!("Count: {}", self.count))
// SharedString (most efficient)
.child(self.title.clone())
}
}
SharedString
use gpui::*;
struct MyView {
title: SharedString,
}
impl MyView {
fn new() -> Self {
Self {
title: "Default Title".into(),
}
}
fn set_title(&mut self, title: impl Into<SharedString>) {
self.title = title.into();
}
}
// SharedString implements IntoElement
impl Render for MyView {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
div().child(self.title.clone())
}
}
Conditional Rendering
when() Method
div()
.when(condition, |this| {
this.bg(rgb(0x3b82f6))
.child("Condition is true")
})
when_some() for Options
div()
.when_some(maybe_text, |this, text| {
this.child(text)
})
Practical Example
struct MyView {
is_active: bool,
error: Option<String>,
}
impl Render for MyView {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
div()
.when(self.is_active, |this| {
this.bg(rgb(0x22c55e))
})
.when_some(self.error.clone(), |this, error| {
this.child(
div()
.p_2()
.bg(rgb(0xef4444))
.text_color(rgb(0xffffff))
.child(error)
)
})
}
}
Custom Components
RenderOnce Components
use gpui::*;
#[derive(IntoElement)]
struct Button {
label: SharedString,
on_click: Option<Box<dyn Fn(&mut App) + 'static>>,
}
impl Button {
fn new(label: impl Into<SharedString>) -> Self {
Self {
label: label.into(),
on_click: None,
}
}
fn on_click(mut self, handler: impl Fn(&mut App) + 'static) -> Self {
self.on_click = Some(Box::new(handler));
self
}
}
impl RenderOnce for Button {
fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {
let mut element = div()
.px_4()
.py_2()
.bg(rgb(0x3b82f6))
.text_color(rgb(0xffffff))
.rounded(px(6.0))
.cursor_pointer()
.child(self.label);
if let Some(handler) = self.on_click {
element = element.on_click(move |_event, _window, cx| {
handler(cx);
});
}
element
}
}
// Usage
impl Render for MyView {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
div().child(
Button::new("Click Me")
.on_click(|cx| {
println!("Button clicked!");
})
)
}
}
Render Components
struct Card {
title: SharedString,
content: SharedString,
}
impl Render for Card {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
div()
.p_4()
.bg(rgb(0x1a1a1a))
.rounded(px(8.0))
.flex()
.flex_col()
.gap_2()
.child(
div()
.text_lg()
.font_bold()
.child(self.title.clone())
)
.child(
div()
.text_sm()
.child(self.content.clone())
)
}
}
Layout Patterns
Vertical Stack
div()
.flex()
.flex_col()
.gap_4()
.child("Item 1")
.child("Item 2")
Установить gpui-elements в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл gpui-elements?
UI element creation and composition with GPUI. Use when building element trees, creating custom components, implementing layouts, or working with conditional rendering.
Как установить скилл gpui-elements?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл gpui-elements запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic