Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)29k · #9361

mastra-frontend

Skill này làm gì

Skill này giải thích cách xây dựng giao diện người dùng bằng hệ thống thiết kế playground của Mastra. Nó hướng agent dùng các thành phần và công cụ bố cục có sẵn, thay vì tự đặt màu và kích thước.

Khi nào nên dùng

  • ✓Khi bạn đang xây dựng một trang hoặc thành phần cho ứng dụng Mastra.
  • ✓Khi bạn muốn giao diện nhất quán với hệ thống thiết kế Mastra.
  • ✓Khi bạn đang thêm bố cục hoặc kiểu dáng vào một ứng dụng dùng các thành phần thiết kế Mastra.

Liên kết skill

https://github.com/mastra-ai/mastra/blob/main/.claude/skills/mastra-frontend/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/mastra-ai/mastra/blob/main/.claude/skills/mastra-frontend/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Xây dựng trang cài đặt cho ứng dụng Mastra của tôi bằng các thành phần hệ thống thiết kế hiện có.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent trước hết tìm các thành phần có sẵn phù hợp với công việc, rồi sắp xếp chúng bằng tiện ích bố cục. Nó tránh viết tay màu sắc và phông chữ, vì hệ thống thiết kế đã cung cấp diện mạo.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Building Frontend Interfaces

Every Mastra application UI is assembled from the @mastra/playground-ui design system. Building a screen is composition work: pick existing components, arrange them with layout utilities, and let the design system provide the look. Writing colors, font sizes, shadows, or radii by hand means you have left the happy path. Changing the design system itself (tokens, ds/ components, variants) is a separate, explicitly-approved task. For Tailwind v4 mechanics (renames, dynamic utilities, CSS-first APIs), read the tailwind-v4 skill.

The boundary: look vs layout

  • Look — colors, typography, radius, shadows, borders, internal padding — belongs to the design system. Consumers never restyle it.
  • Layout — positioning, flex/grid placement, gap-*, margins, size constraints (w-*, max-w-*, min-h-*, shrink-0) — belongs to the consumer, through Tailwind utilities on your own wrappers and, when needed, directly on DS components.

className on a DS component is fine for layout (<DialogContent size="xl" className="h-[80vh]">, where size picks the width and the class only pins the height) and forbidden for look (<Button className="bg-red-500 text-xs">). If a component's look doesn't fit, use its variants and props; if none fit, escalate for a new variant instead of overriding.

Find what exists — never guess, never rebuild

  • Components: browse packages/playground-ui/src/ds/components/ (primitives) and src/domains/ (feature components). Check the exports and existing usage before building anything new.
  • Tokens: read the @theme blocks under packages/playground-ui/theme/ (colors, status, data-viz, surfaces, typography, scale, motion), all imported by packages/playground-ui/theme.css, which holds the semantic aliases. The namespace tells you the generated utility: --color-x → bg-x/text-x/border-x, --spacing-x → p-x/gap-x/h-x, --text-x → text-x, --shadow-x → shadow-x, --radius-x → rounded-x. Token names drift — confirm them in the file, never use them from memory.

Choosing a class value

Pick the highest rung that fits; each step down needs a reason:

  1. DS component or variant — the look you need probably already exists.
  2. Generated theme utility from theme.css.
  3. Dynamic v4 utility when the value maps to the spacing scale (min-w-100, size-6, grid-cols-15).
  4. Local CSS custom property consumed via shorthand, for runtime values scoped to one component (bg-(--row-bg), text-(color:--agent-color-fg)).
  5. Square-bracket arbitrary value only for a justified one-off (max-h-[calc(100dvh-3rem)]).

Theme contract

  • theme.css variables are API: adding one generates utilities for every consumer. Never modify theme.css, its layers in packages/playground-ui/theme/, or packages/playground-ui/src/ds/tokens/*.ts without explicit approval. To request a token: document the use case, explain why a local CSS custom property is not enough, and wait for the design team.
  • Runtime-only or single-component values get a plain CSS custom property (which generates no utility) consumed via bg-(--var) — not a new @theme token.
  • When JavaScript needs a theme value, read the CSS variable (var(--color-surface4), getComputedStyle) — never resolveConfig or JS token imports for styling.

Wiring

  • packages/playground-ui/components.css is the design system's stylesheet uncompiled: theme.css, the dark variant (@custom-variant dark (&:is(.dark *))), custom utilities, base styles and keyframes. src/index.css is @import 'tailwindcss' plus that file, for the library build. An app with its own Tailwind build imports components.css and sources.css into its sheet instead of style.css.
  • The palette defaults to dark in :root; html.light flips the semantic variables. Theming is automatic through semantic tokens — never write dark: color overrides on semantic tokens; reserve dark: for rare structural differences.
  • Build conditional or merged class strings with cn() — exported from @mastra/playground-ui for consumers, src/lib/utils.ts inside the package. Its twMerge is extended with the DS scales (src/lib/tw-merge-config.ts), so DS utilities like text-body-sm merge correctly; importing twMerge from tailwind-merge directly mis-merges them.
  • Code inside packages/playground-ui outside ds/ (for example src/domains/) is itself a consumer of the ds/
Câu hỏi thường gặp

Tôi có thể đổi màu không?

Không trực tiếp trong một màn hình. Diện mạo đến từ hệ thống thiết kế, và thay đổi hệ thống là một công việc riêng.

Nếu không có thành phần nào phù hợp thì sao?

Skill khuyên yêu cầu một biến thể mới thay vì ghi đè diện mạo hiện có.

Nó có bao gồm kiểu dáng Tailwind không?

Có. Nó dùng các tiện ích Tailwind cho bố cục, như khoảng cách và kích thước trên các wrapper của riêng bạn.

Chi tiết

Mô tả gốc của tác giả

How to build Mastra frontend interfaces with the @mastra/playground-ui design system. This skill should be used when creating or modifying any application UI — pages, components, styling, or tokens — in this repo or in an external consumer of the design system. The docs site has its own styling and is out of scope.

repo: mastra-ai/mastra

Độ phổ biến

Sao GitHub
29k
Vị trí xếp hạng
#9361
Giấy phép
—
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự