web-component-design
できること
このツールは、Webサイトやアプリで再利用できる整理されたユーザーインターフェースのコンポーネントを作る手助けをします。React、Vue、Svelteなどの技術を使い、効率よく見栄えのよいコンポーネントを作るパターンを紹介します。
使う場面
- ✓プロジェクト用のビジュアルコンポーネントのライブラリを作るとき。
- ✓ボタンやカードなどの要素の見た目と動作を設計するとき。
- ✓コンポーネントに色、フォント、サイズなどのスタイルをどう適用するか決めるとき。
スキルのリンク
https://github.com/wshobson/agents/blob/main/plugins/ui-design/skills/web-component-design/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“色やアイコンを変えられる再利用可能なボタンを、Reactでどのように作ればよいですか?”
毎週5つの新しいスキル。1分で読めます。
仕組み
このツールは、コンポーネントを組み合わせて互いにうまく機能させる方法を紹介します。たとえば「コンパウンドコンポーネント」や「スロット」といった手法があります。また、CSS-in-JSなど、コンポーネントにスタイルを適用するさまざまな方法も紹介します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Web Component Design
Build reusable, maintainable UI components using modern frameworks with clean composition patterns and styling approaches.
When to Use This Skill
- Designing reusable component libraries or design systems
- Implementing complex component composition patterns
- Choosing and applying CSS-in-JS solutions
- Building accessible, responsive UI components
- Creating consistent component APIs across a codebase
- Refactoring legacy components into modern patterns
- Implementing compound components or render props
Core Concepts
1. Component Composition Patterns
Compound Components: Related components that work together
// Usage
<Select value={value} onChange={setValue}>
<Select.Trigger>Choose option</Select.Trigger>
<Select.Options>
<Select.Option value="a">Option A</Select.Option>
<Select.Option value="b">Option B</Select.Option>
</Select.Options>
</Select>
Render Props: Delegate rendering to parent
<DataFetcher url="/api/users">
{({ data, loading, error }) =>
loading ? <Spinner /> : <UserList users={data} />
}
</DataFetcher>
Slots (Vue/Svelte): Named content injection points
<template>
<Card>
<template #header>Title</template>
<template #content>Body text</template>
<template #footer><Button>Action</Button></template>
</Card>
</template>
2. CSS-in-JS Approaches
| Solution | Approach | Best For |
|---|---|---|
| Tailwind CSS | Utility classes | Rapid prototyping, design systems |
| CSS Modules | Scoped CSS files | Existing CSS, gradual adoption |
| styled-components | Template literals | React, dynamic styling |
| Emotion | Object/template styles | Flexible, SSR-friendly |
| Vanilla Extract | Zero-runtime | Performance-critical apps |
3. Component API Design
interface ButtonProps {
variant?: "primary" | "secondary" | "ghost";
size?: "sm" | "md" | "lg";
isLoading?: boolean;
isDisabled?: boolean;
leftIcon?: React.ReactNode;
rightIcon?: React.ReactNode;
children: React.ReactNode;
onClick?: () => void;
}
Principles:
- Use semantic prop names (
isLoadingvsloading) - Provide sensible defaults
- Support composition via
children - Allow style overrides via
classNameorstyle
Quick Start: React Component with Tailwind
import { forwardRef, type ComponentPropsWithoutRef } from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
const buttonVariants = cva(
"inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50",
{
variants: {
variant: {
primary: "bg-blue-600 text-white hover:bg-blue-700",
secondary: "bg-gray-100 text-gray-900 hover:bg-gray-200",
ghost: "hover:bg-gray-100 hover:text-gray-900",
},
size: {
sm: "h-8 px-3 text-sm",
md: "h-10 px-4 text-sm",
lg: "h-12 px-6 text-base",
},
},
defaultVariants: {
variant: "primary",
size: "md",
},
},
);
interface ButtonProps
extends
ComponentPropsWithoutRef<"button">,
VariantProps<typeof buttonVariants> {
isLoading?: boolean;
}
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, isLoading, children, ...props }, ref) => (
<button
ref={ref}
className={cn(buttonVariants({ variant, size }), className)}
disabled={isLoading || props.disabled}
{...props}
>
{isLoading && <Spinner className="mr-2 h-4 w-4" />}
{children}
</button>
),
);
Button.displayName = "Button";
Framework Patterns
React: Compound Components
import { createContext, useContext, useState, type ReactNode } from "react";
interface AccordionContextValue {
openItems: Set<string>;
toggle: (id: string) => void;
}
const AccordionContext = createContext<AccordionContextValue | null>(null);
function useAccordion() {
const context = useContext(AccordionContext);
if (!context) throw new Error("Must be used within Accordion");
return context;
}
export function Accordion({ children }: { children: ReactNode }) {
…
よくある質問
「コンパウンドコンポーネント」とは何ですか?
一連のまとまりとして働くコンポーネントのことです。たとえばセレクト(選択)コンポーネントには、選択中の項目を表示する部分、選択肢の一覧、一覧の各項目といった別々のパーツがありますが、全体で1つの部品として機能します。
「CSS-in-JS」とは何ですか?
スタイルのコード(CSS)を、コンポーネントのコード(JavaScriptやTypeScript)の中に直接書く方法です。より柔軟で整理されたスタイル指定ができます。
「コンポーネントAPI設計」とは何を意味しますか?
コンポーネントが受け取るオプションやプロパティ(色、サイズ、無効化の有無など)をどう定義するかを指します。他の開発者が簡単に使えるようにするためのものです。
詳細
作者による元の説明
Master React, Vue, and Svelte component patterns including CSS-in-JS, composition strategies, and reusable component architecture. Use when building UI component libraries, designing component APIs, or implementing frontend design systems.
repo: wshobson/agents
人気
- GitHubのスター
- 41k
- ランキング
- #6809
- ライセンス
- MIT
- 更新日
- 2026/10/15
コメント
- …
このリポジトリの他のスキル
screen-reader-testing
41kエージェントにスクリーンリーダーを使ってWebサイトをテストさせ、アクセシビリティを確認します。
wcag-audit-patterns
41kエージェントがWebサイトのアクセシビリティを監査し、WCAGガイドラインに沿って問題を修正できるようにします。
multi-reviewer-patterns
41kエージェントが複数のコードレビューを並行して調整できるようにします。指摘事項の重複を排除し、レポートにまとめます。
parallel-debugging
41kエージェントが並行調査と根本原因分析を使って、複雑な問題をデバッグできるようにします。
似ているスキル
canvas
394k接続されたMacのパネルにホスト型のビジュアルウィジェットを表示し、そのパネルを隠したり別のページに移動したりするようエージェントを支援します。
control-ui
394kセッション、ダッシュボード、接続されたGatewayを含め、OpenClaw Control UIを整理し、問題を解決するようエージェントを支援します。
diagram-maker
394kプロセス、システムのアーキテクチャ、ホワイトボードのスケッチのために、SVG、HTML、または編集可能なExcalidrawとして、分かりやすい図を作るようエージェントを支援します。