Communitygithub.com

coastdigitalgroup/coastai-skills

Design and implement a fluid spacing scale using CSS clamp() to ensure consistent white space and vertical rhythm across all devices. Trigger this skill when asked to define spacing systems, margins, paddings, or layout gaps.

coastai-skills 是什麼?

coastai-skills is a Claude Code agent skill that design and implement a fluid spacing scale using CSS clamp() to ensure consistent white space and vertical rhythm across all devices. Trigger this skill when asked to define spacing systems, margins, paddings, or layout gaps.

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

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Fluid Spacing System

Purpose

The Fluid Spacing System skill provides a methodology for creating a responsive scale of white space (margins, paddings, gaps) that adapts smoothly to the user's viewport. By using the CSS clamp() function, spacing scales linearly between defined minimum and maximum values, maintaining visual harmony and consistent proportions without the need for excessive media queries.

Use Cases

  • Establishing a foundational spacing scale for a new design system.
  • Modernizing a website to improve visual consistency across mobile, tablet, and desktop.
  • Designing high-quality layouts where white space needs to breathe on large screens but stay compact on small ones.
  • Replacing fixed pixel-based spacing with a more flexible, implementation-aware system.

When NOT to Use

  • Simple, Non-Responsive Pages: If the layout is extremely basic or has no responsive requirements.
  • Strictly Fixed Layouts: When the design specifications mandate exact, non-negotiable pixel values at every resolution.
  • Legacy Browser Support: If the target audience primarily uses browsers that do not support CSS clamp() (e.g., Internet Explorer).

Inputs

To generate a fluid spacing system, you need:

  1. Viewport Range:
    • min-width: The screen width where scaling starts (e.g., 320px).
    • max-width: The screen width where scaling stops (e.g., 1280px).
  2. Base Spacing Unit:
    • min-size: The base unit (e.g., 16px) at min-width.
    • max-size: The base unit (e.g., 20px) at max-width.
  3. Scale Ratio:
    • A multiplier to determine the steps in the scale (e.g., 1.25 for a Major Third scale, or a linear 2x/3x/4x progression).

Outputs

  1. Fluid Spacing Scale: A set of CSS variables defining values from "tiny" to "huge" using clamp().
  2. Semantic Mapping: Guidelines on how to apply these tokens (e.g., --space-m for component padding, --space-xl for section margins).
  3. Usage Documentation: Rules for combining units to maintain vertical rhythm and horizontal alignment.

Workflow

1. Define the Scale Parameters

Set the boundaries for your fluid system based on the project's target devices. Example: 320px (Mobile) to 1440px (Desktop), with a base unit scaling from 16px to 24px.

2. Choose a Spacing Ratio

Decide how the spacing steps should grow.

  • Linear/Multiplicative: Steps are multiples of the base unit (e.g., 0.5x, 1x, 1.5x, 2x, 4x, 8x). Best for predictable alignment.
  • Geometric Scale: Each step is the previous step multiplied by a ratio (e.g., 1.25). Best for high-contrast, artistic layouts.

3. Calculate Scale Steps

Create a range of sizes. A typical scale includes:

  • 3XS to XS: For tiny details, tight lists, and internal button padding.
  • S to M: For standard component spacing and gutters.
  • L to 3XL: For section margins, hero spacing, and major layout gaps.

4. Generate CSS clamp() Formulas

Convert pixel values into fluid formulas. clamp(min_rem, intercept_rem + slope_vw, max_rem)

Slope calculation: (max_px - min_px) / (max_viewport - min_viewport) * 100

5. Assign Semantic Roles

Map the abstract scale to functional roles to ensure consistency across the team.

  • space-component: --space-s
  • space-layout-gutter: --space-m
  • space-section: --space-xl

Decision Rules

  • The 8pt Grid Principle: Whenever possible, ensure your min/max values are multiples of 4 or 8 to align with standard UI patterns.
  • Proximity Principle: Elements that are related should have less space between them than elements that are unrelated.
  • Mobile Compression: Keep smaller spacing units (3XS-S) relatively stable; only larger units (L-3XL) should scale aggressively to prevent mobile layouts from feeling "exploded."
  • Accessibility: Ensure that even at the smallest scale, interactive elements maintain a large enough hit area (minimum 24x24px per WCAG 2.2 SC 2.5.8, including padding; 44x44px preferred for primary actions).
  • Container-Relative Spacing: For spacing that should respond to a component's container rather than the viewport (e.g., a card that can sit in a narrow sidebar or a wide main column), use container query length units (cqi/cqw) inside the clamp() formula instead of vw.

Constraints

  • Responsiveness: Spacing should never cause horizontal overflow.
  • Consistency: Once a scale is defined, do not use "one-off" pixel values.
  • Hierarchy: Larger spacing should always be used to separate larger blocks of content (e.g., sections), while smaller spacing is for internal component details.
  • Scope: This skill covers spacing values only — it does not create a layout grid (use responsive-grid-system), define typography sizes (use fluid-typography-system), or manage z-index/layering.

Common Failure Patterns

  • Scaling Everything Equally: Scaling small paddings (like 4px) too much can make components look distorted on desktop.
  • Ignoring Layout Gutters: Having fluid component spacing but fixed grid gutters, leading to alignment "drift."
  • Overwhelming Scale: Having 20+ different spacing steps makes the system hard to use and maintain. Aim for 7-9 steps.
  • No Logical Steps: Using arbitrary numbers instead of a consistent scale or ratio.

Validation Criteria

  • Spacing scales smoothly when the viewport is resized.
  • Vertical rhythm is maintained across all major breakpoints.
  • No "one-off" pixel values are used in the implementation; all spacing uses the defined variables.
  • The system uses rem units for the minimum and maximum bounds of the clamp() function.
  • Proximity and hierarchy are reinforced by the spacing choices.
  • Interactive elements retain at least a 24x24px hit area (WCAG 2.2 SC 2.5.8) at every point on the fluid scale, including the smallest viewport.

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.

相關技能