コンポーネント
components ブロックは、名前付きの UI コンポーネントを design tokens に裏付けられた具体的なスタイルプロパティへマッピングします。
コンポーネントプロパティ
DESIGN.md 仕様では、各コンポーネントエントリに以下の規範的プロパティを指定できます。
| プロパティ | 期待される値 |
|---|---|
backgroundColor | カラーリテラルまたは {colors.*} 参照 |
textColor | カラーリテラルまたは {colors.*} 参照 |
typography | 複合 {typography.*} 参照 |
rounded | 寸法リテラルまたは {rounded.*} 参照 |
padding | 寸法リテラルまたは {spacing.*} 参照 |
size | 寸法リテラルまたは {spacing.*} 参照 |
height | 寸法リテラルまたは {spacing.*} 参照 |
width | 寸法リテラルまたは {spacing.*} 参照 |
components:
button-primary:
backgroundColor: "{colors.primary}"
textColor: "{colors.on-primary}"
typography: "{typography.label-md}"
rounded: "{rounded.md}"
padding: 12pxグローバルトークンカテゴリーとは異なり、components ではプリミティブな {colors.*}、{rounded.*}、{spacing.*} に加えて、複合トークン {typography.*} への参照も許可されます。
インタラクティブ状態は兄弟エントリとして定義する
hover、active、focus、disabled といった状態は、コンポーネント配下にネストするのではなく、フラットな兄弟キーとして表現します。
components:
button-primary:
backgroundColor: "{colors.primary}"
textColor: "{colors.on-primary}"
rounded: "{rounded.md}"
padding: 12px
button-primary-hover:
backgroundColor: "#3730a3"
textColor: "{colors.on-primary}"
rounded: "{rounded.md}"
padding: 12px
button-primary-disabled:
backgroundColor: "{colors.surface}"
textColor: "{colors.text-muted}"
rounded: "{rounded.md}"
padding: 12px状態をフラットに保つことで、すべてのエントリがシンボルテーブル内で均一に解決され(components.button-primary-hover.backgroundColor)、各ツールへきれいにエクスポートできます。
本文(Prose)に書くべき内容
ボーダー、ボックスシャドウ、内部の flex/grid ギャップ、アイコンサイズのルール、レスポンシブの積み重ね挙動などには、YAML の components スキーマに専用プロパティがありません。YAML スキーマを肥大化させずに構造ガイドラインをエージェントへ伝えるため、これらは ## Components Markdown セクションに記述します。
## Components
- **Primary button (`button-primary`):** Minimum width `96px`, `1px` transparent border to prevent layout shift when paired with outlined secondary buttons, and `8px` gap between icon and label.
- **Card surface (`card-surface`):** Use a `1px solid` `{colors.border}` hairline instead of drop shadows on desktop grids.外部テンプレート参照
コンポーネントからは、以下のようなインラインコード参照を使ってリファレンス HTML やコンポーネントスニペットを指し示すことができます。
@components/button.html@components/card.html#card-elevated
パスは DESIGN.md が置かれているディレクトリからの相対パスとして解決されます。
コンポーネントの自動コントラストチェック
DESIGN.md を DesignMD Pro バリデーターに貼り付けると、リンターはすべてのコンポーネントの前景色プロパティ(color、text、textColor、foreground)と背景色プロパティ(background、backgroundColor、bg、surface、fill)の組み合わせを検査します。
- コントラスト比
3:1未満 → エラー(low-contrast) - コントラスト比
3:1〜4.49:1→ 警告(low-contrast) - コントラスト比
4.5:1以上 → 通常テキストの WCAG AA 基準を通過
たとえば上記の button-primary-disabled でも、{colors.surface}(#f6f5f4)に対する {colors.text-muted}(#52525b)を検証することで、無効化ラベルの可読性を維持できます。
次のステップ
- 本文セクション — 他の順序付きセクションと併せて
## Components本文を記述する - 完全なサンプル — 複数コンポーネントを備えた完全な
DESIGN.mdを確認する - バリデーターと Lint ルール — すべての参照チェックとコントラストチェックを確認する