CSS Clamp – fluid typography and spacing

    by Willem-Jaap Klepper

    1

    Generate fluid CSS clamp() values for font sizes, spacing and type scales. Includes a script that does the maths, so values are exact and accessible (rem-based, zoom-safe). Works with plain CSS and Tailwind CSS.

    Free

    2 usesSecurity scanned

    Works with the AI Agents you already use

    CSS Clamp – fluid typography and spacing

    Example session with this skill installed

    Make my headings fluid between 360px and 1440px viewports: body 16px to 18px, h3 20px to 28px, h2 24px to 40px, h1 36px to 64px. Give me Tailwind CSS v4 @theme tokens.

    • Read your context and instructions
    • Compiled the css clamp

    Ran node scripts/clamp.mjs for each size between 360px and 1440px. Bounds and intercepts are in rem, so the text still scales with browser zoom, and every max stays under 2.5x its min (WCAG 1.4.4).

    TokenMinMaxValue
    body16px18pxclamp(1rem, 0.958rem + 0.185vw, 1.125rem)
    h320px28pxclamp(1.25rem, 1.083rem + 0.741vw, 1.75rem)
    h224px40pxclamp(1.5rem, 1.167rem + 1.481vw, 2.5rem)
    h136px64pxclamp(2.25rem, 1.667rem + 2.593vw, 4rem)
    @import "tailwindcss";
    
    @theme {
      --text-body: clamp(1rem, 0.958rem + 0.185vw, 1.125rem);
      --text-h3: clamp(1.25rem, 1.083rem + 0.741vw, 1.75rem);
      --text-h2: clamp(1.5rem, 1.167rem + 1.481vw, 2.5rem);
      --text-h1: clamp(2.25rem, 1.667rem + 2.593vw, 4rem);
    }
    

    Use them as text-body, text-h3, text-h2 and text-h1, for example <h1 class="text-h1 font-bold">.

    Check: at 360px the h1 is 1.667rem + 2.593vw = 26.67px + 9.33px = 36px. At 1440px it is 26.67px + 37.34px = 64px.

    Next steps: pair each size with a line height (around 1.1 to 1.2 for headings), and for components inside a sidebar or card, rerun with --unit cqi so they scale with their container instead of the viewport.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Teaches AI coding agents to generate correct, accessible CSS clamp() values for fluid typography, spacing and complete type scales. The agent runs a bundled Node script instead of doing the maths by hand. It follows accessibility rules (rem bounds, no bare vw for text, the 2.5x zoom rule for WCAG 1.4.4) and outputs plain CSS, custom properties or Tailwind CSS v3/v4 tokens.

    Does not handle layout structural changes like column counts. Requires Node.js for the calculation script, otherwise falls back to manual formula application.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    2 uses

    Times used to date

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 2 months ago

    • Free with an Agensi account

    Permissions

    Terminal / Shell
    Listed2 months ago

    What's inside

    Creator

    Willem-Jaap Klepper

    Willem-Jaap Klepper

    Frequently Asked Questions

    This skill provides a pre-configured workflow and an optimized Node script that allows AI agents to calculate perfect fluid scaling values (clamp) for typography and spacing without manual mathematical errors.

    The skill is compatible with any AI coding agent that has a filesystem or terminal access (such as Claude Engineer, Aider, or Cursor) and supports plain CSS, CSS Custom Properties, and Tailwind CSS v3/v4 configurations.

    Yes, the generated clamp values utilize rem units and avoid bare viewport units for text, ensuring your designs comply with WCAG 1.4.4 accessibility standards regarding 2.5x browser zoom.

    You will receive the proprietary system instructions for the agent, the specialized Node calculation script, and documentation on how to integrate the skill into your existing developer workflow.

    Setting up is as simple as adding the provided script to your project directory and giving your AI agent the specific instructions included; no complex API keys or external subscriptions are required.

    New in Frontend & Web Apps

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Frontend & Web Apps.

    Free