components/card
데이터 표시 · 21 / 64

Card

ui.widgets.Card

제목, 본문, 상호작용 표면을 하나의 시각 단위로 묶습니다.

BEHAVIOR CONTRACT

default / outlined / elevated, selected, hoverable, interactive, padding 정책을 명시적으로 구분합니다.

RECORDED INTERACTION

변형과 각종 상호작용 상태를 보여 줍니다.

examples/storybook/stories.zig:497
// ── Card ──
pub fn buildCard(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const a = cx.allocator;
    const c = try col(cx, 12);

    // ── 变体 ──
    try c.appendChild(a, try label(cx, "Variants (default / outlined / elevated)"));
    try c.appendChild(a, try W.Card(.{ .title = "Default", .subtitle = "with subtitle", .variant = .default, .width = 320 }).mount(scope, cx));
    try c.appendChild(a, try W.Card(.{ .title = "Outlined", .variant = .outlined, .width = 320 }).mount(scope, cx));
    try c.appendChild(a, try W.Card(.{ .title = "Elevated", .variant = .elevated, .width = 320 }).mount(scope, cx));

    // ── body ──
    try c.appendChild(a, try label(cx, "With body"));
    const res = try W.Card(.{ .title = "Card with body", .width = 320 }).mountBody(scope, cx);
    try res.body.appendChild(a, try ui.text(cx, "Body content goes here.", .{ .font_size = 13, .color = light.color.fg_secondary }));
    try c.appendChild(a, res.card);

    // ── 交互态 ──
    try c.appendChild(a, try label(cx, "States (selected / hoverable / interactive / no-pad)"));
    try c.appendChild(a, try W.Card(.{ .title = "Selected", .selected = true, .width = 320 }).mount(scope, cx));
    try c.appendChild(a, try W.Card(.{ .title = "Hoverable", .hoverable = true, .width = 320 }).mount(scope, cx));
    try c.appendChild(a, try W.Card(.{ .title = "Interactive", .interactive = true, .width = 320 }).mount(scope, cx));
    try c.appendChild(a, try W.Card(.{ .title = "No padding", .padded = false, .width = 320 }).mount(scope, cx));
    return c;
}
GitHub에서 소스 보기examples/storybook/stories.zig:497

Storybook에 있는 이 story의 원본 코드입니다(zenit 5f9add5+wip 2026-09-30). W는 ui.widgets이며, col / row / label은 Storybook 내부의 작은 레이아웃 헬퍼입니다.

zenit · 이중 라이선스오픈 소스 프로젝트는 GPL-3.0-only로 무료 사용할 수 있으며, 비공개 소스나 상용 제품에는 상용 라이선스가 필요합니다.작성자 연락처: zongyi.xzy#gmail.com (#을 @로 바꾸세요)zenit 5f9add5+wip 2026-09-30