Communitygithub.com

coastdigitalgroup/coastai-skills

CSSのclamp()を用いた流体的スペーシングスケールを設計・実装します。一貫した余白と垂直リズムを全デバイスで実現します。スペーシングシステム、マージン、パディング、レイアウトのギャップについて質問されたときにこのスキルを起動してください。

coastai-skills とは?

Fluid Spacing Systemスキルは、CSSの`clamp()`関数を活用して、画面サイズに応じてスムーズに変化するスペーシング(余白、パディング、ギャップ)のスケールを生成するための体系的な手法を提供します。このスキルは、デザインシステムの基盤となるスペーシングスケールの構築や、モバイル・タブレット・デスクトップ間での視覚的一貫性の向上を目的とする開発者やデザイナー向けに設計されています。ユーザーはビューポート範囲、ベーススペーシング単位、スケール比率を入力として与えることで、`clamp()`を用いたCSS変数のセット(`--space-xs` から `--space-3xl` まで)と、それらのセマンティックなマッピングルールを出力として得られます。また、8ptグリッド原則、近接原則、アクセシビリティ(最低24x24pxのヒット領域)などの判断ルールや、過度なスケール展開を避けるベストプラクティスも含まれており、現代的で保守的なスペーシングシステムを効率的に実装できます。対応プラットフォームはあらゆるWebプロジェクトで、特にCSS `clamp()` をサポートするモダンブラウザを対象とします。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/coastdigitalgroup/coastai-skills/tree/HEAD/website-design/fluid-spacing-system

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Fluid Spacing System(流体的スペーシングシステム)

目的

Fluid Spacing Systemスキルは、ユーザーのビューポートに応じてスムーズに適応する余白(マージン、パディング、ギャップ)のレスポンシブスケールを作成するための方法論を提供します。CSSのclamp()関数を使用することで、スペーシングは定義された最小値と最大値の間で線形にスケーリングし、過剰なメディアクエリを必要とせずに視覚的な調和と一貫した比率を維持します。

ユースケース

  • 新しいデザインシステムの基礎となるスペーシングスケールの確立
  • モバイル、タブレット、デスクトップ間での視覚的一貫性を向上させるためのWebサイトのモダナイゼーション
  • 大きな画面では余白が呼吸し、小さな画面ではコンパクトに保つ必要がある高品質なレイアウトの設計
  • 固定ピクセルベースのスペーシングから、より柔軟で実装を意識したシステムへの置き換え

使用すべきでないケース

  • シンプルで非レスポンシブなページ: レイアウトが極めて基本的であるか、レスポンシブ対応の要件がない場合。
  • 厳密に固定されたレイアウト: デザイン仕様が全ての解像度で正確で変更不可なピクセル値を要求する場合。
  • レガシーブラウザのサポート: ターゲットユーザーが主にCSS clamp() をサポートしていないブラウザ(例:Internet Explorer)を使用している場合。

入力

流体的スペーシングシステムを生成するには、以下が必要です:

  1. ビューポート範囲:
    • min-width: スケーリングが開始される画面幅(例:320px)。
    • max-width: スケーリングが停止する画面幅(例:1280px)。
  2. ベーススペーシング単位:
    • min-size: min-width でのベース単位(例:16px)。
    • max-size: max-width でのベース単位(例:20px)。
  3. スケール比率:
    • スケールのステップを決定する乗数(例:1.25の長三度スケール、または線形の2x/3x/4x進行など)。

出力

  1. Fluid Spacing Scale(流体的スペーシングスケール): clamp() を使用して「極小」から「極大」までの値を定義するCSS変数のセット。
  2. セマンティックマッピング: これらのトークンを適用する方法に関するガイドライン(例:--space-m をコンポーネントのパディングに、--space-xl をセクションのマージンに)。
  3. 使用ドキュメント: 垂直リズムと水平方向の整列を維持するために単位を組み合わせるためのルール。

ワークフロー

1. スケールパラメータの定義

プロジェクトのターゲットデバイスに基づいて、流体システムの境界を設定します。 例: 320px(モバイル)から1440px(デスクトップ)まで、ベース単位は16pxから24pxにスケーリング。

2. スペーシング比率の選択

スペーシングステップがどのように増加するかを決定します。

  • 線形/乗算: ステップはベース単位の倍数(例:0.5x、1x、1.5x、2x、4x、8x)。予測可能な整列に最適。
  • 幾何級数スケール: 各ステップは前のステップに比率(例:1.25)を掛けた値。コントラストの高いアーティスティックなレイアウトに最適。

3. スケールステップの計算

サイズの範囲を作成します。典型的なスケールは以下を含みます:

  • 3XS~XS: 細かい詳細、タイトなリスト、内部ボタンのパディング用。
  • S~M: 標準的なコンポーネントのスペーシングとガター用。
  • L~3XL: セクションのマージン、ヒーロースペーシング、主要なレイアウトギャップ用。

4. CSS clamp() 式の生成

ピクセル値を流体式に変換します。 clamp(min_rem, intercept_rem + slope_vw, max_rem)

傾きの計算: (max_px - min_px) / (max_viewport - min_viewport) * 100

5. セマンティックロールの割り当て

抽象的なスケールを機能的なロールにマッピングし、チーム全体での一貫性を確保します。

  • space-component(コンポーネントスペース):--space-s
  • space-layout-gutter(レイアウトガター):--space-m
  • space-section(セクションスペース):--space-xl

判断ルール

  • 8ptグリッドの原則: 可能な限り、最小値と最大値が4または8の倍数になるようにして、標準的なUIパターンと整合させます。
  • 近接の原則: 関連する要素間のスペースは、関連しない要素間よりも小さくする必要があります。
  • モバイル圧縮: 小さなスペーシング単位(3XS~S)は比較的安定させ、大きな単位(L~3XL)だけを積極的にスケーリングして、モバイルレイアウトが「爆発した」ように感じられるのを防ぎます。
  • アクセシビリティ: 最小スケールでも、インタラクティブ要素が十分なヒット領域(WCAG 2.2 SC 2.5.8に従い、パディングを含めて最低24x24px、プライマリアクションには44x44px推奨)を維持するようにします。
  • コンテナ相対スペーシング: ビューポートではなくコンポーネントのコンテナに応答するスペーシング(例:狭いサイドバーまたは広いメインカラムに配置できるカード)の場合は、clamp() 式内で vw の代わりにコンテナクエリ長さ単位(cqi/cqw)を使用します。

制約条件

  • レスポンシブ性: スペーシングによって水平方向のオーバーフローが発生してはなりません。
  • 一貫性: スケールが定義されたら、「一回限りの」ピクセル値を使用しないでください。
  • 階層構造: 大きなスペーシングは常に大きなコンテンツブロック(例:セクション)を区切るために使用し、小さなスペーシングは内部コンポーネントの詳細に使用します。
  • 範囲: このスキルはスペーシング値のみをカバーします。レイアウトグリッドの作成(responsive-grid-system を使用)、タイポグラフィサイズの定義(fluid-typography-system を使用)、またはz-index/レイヤリングの管理は行いません。

よくある失敗パターン

  • すべてを均等にスケーリングする: 小さなパディング(例:4px)を大きくスケーリングしすぎると、デスクトップでコンポーネントが歪んで見える可能性があります。
  • レイアウトガターを無視する: コンポーネントのスペーシングは流動的であるのにグリッドガターは固定されており、位置揃えに「ずれ」が生じる。
  • 過剰なスケール: 20以上の異なるスペーシングステップがあると、システムの使用と保守が困難になります。7~9ステップを目指してください。
  • 論理的なステップがない: 一貫したスケールや比率の代わりに任意の数値を使用する。

検証基準

  • ビューポートをリサイズしたときにスペーシングがスムーズにスケーリングする。
  • すべての主要ブレークポイントで垂直リズムが維持されている。
  • 実装において「一回限りの」ピクセル値が使用されておらず、すべてのスペーシングが定義された変数を使用している。
  • システムは clamp() 関数の最小値と最大値の境界に rem 単位を使用している。
  • 近接性と階層構造がスペーシングの選択によって強化されている。
  • インタラクティブ要素が、最小のビューポートも含め、流体スケール上のすべてのポイントで少なくとも24x24pxのヒット領域(WCAG 2.2 SC 2.5.8)を維持している。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for progressive disclosure using accordions, ensuring structural integrity, visual affordances, and accessibility across different content densities and devices.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for long-form content, managing readability, vertical rhythm, and information density to ensure a superior reading experience.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for informational elements that communicate state (Badges) and categorization (Tags) with clarity and accessibility.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for non-overlay notifications, managing global announcements and contextual inline alerts to communicate system states without interrupting the user's flow.

coastdigitalgroup/coastai-skills

Design and implement a systematic, asymmetrical bento-grid layout framework to organize diverse content types cohesively while maintaining strict visual hierarchy, logical focus order, and responsive flexibility.

coastdigitalgroup/coastai-skills

Design a responsive, mobile-first bottom navigation bar and persistent action dock system for mobile websites and web applications, establishing spatial anchors, tab bar anatomy, badge indicators, thumb-zone ergonomics, safe area inset handling, active/inactive state contrast, and desktop responsive adaptation rules.

coastdigitalgroup/coastai-skills

Design a mobile-first bottom sheet overlay system with configurable detents, drag affordances, safe area padding, responsive desktop modal/popover adaptation, and WCAG AA accessibility compliance.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for secondary navigation trails that provide orientation, context, and one-click access to parent levels in deep information architectures.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for buttons and interactive triggers, managing visual hierarchy, variant logic, and action grouping to ensure clear intent and accessible interaction.

coastdigitalgroup/coastai-skills

Design a systematic framework for date and time selection, managing calendar grids, range pickers, and scheduling interfaces to ensure precision and accessibility.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for modular content containers that maintain hierarchy, structural integrity, and action alignment across variable content and responsive viewports.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for horizontal discovery components, managing navigation affordances, scroll behavior, and accessibility to ensure effective content density without compromising usability.

coastdigitalgroup/coastai-skills

Design a systematic, highly accessible, and developer-friendly UI layout framework for code blocks, snippet showcases, multi-file code tabs, line-highlighting, diff views, and syntax token contrast in technical documentation and developer platforms.

coastdigitalgroup/coastai-skills

Design a systematic framework for global command menus (Cmd+K panels) that combines keyboard-driven navigation, command execution, and shortcut discovery into an accessible, responsive overlay.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for threaded conversations, managing nesting depths, action hierarchies, and community signaling to foster engagement and readability.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for side-by-side comparison interfaces, managing high attribute density and responsive complexity to support informed decision-making.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for user privacy, managing consent banners, preference centers, and persistent privacy controls to balance legal compliance with user trust.

coastdigitalgroup/coastai-skills

Design and implement a systematic, highly accessible, and responsive visual layout framework for conversational chat widgets, live chat boxes, and chatbot panels that ensures clear message scannability, native focus flow, and seamless mobile keyboard adaptation.

coastdigitalgroup/coastai-skills

Design a systematic, accessible, and high-conversion framework for custom select dropdowns and comboboxes, defining anatomy, states, search-filtering, and responsive mobile-adaptive patterns.

coastdigitalgroup/coastai-skills

Design and implement a systematic color palette that ensures WCAG 2.2 accessibility compliance. Trigger this skill when asked to define brand colors, create UI themes, or establish a visual system for a website.

関連スキル