primitive (astro)

Create stateless, CVA-variant UI primitives for the Astro landing and blog app.

4|Updated Jul 30, 2026
One-click install
npx skills add https://github.com/gabriellst/codm --skill primitive-astro-gabriellst
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: primitive (astro)
Source: https://github.com/gabriellst/codm/tree/main/.claude/skills/primitive/astro
Command: npx skills add https://github.com/gabriellst/codm --skill primitive-astro-gabriellst

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires class-variance-authority.

What problem does it solve? Building reusable UI components for an Astro site often leads to unnecessary React islands, duplicated variant components, and hardcoded colors that break theming. This Skill enforces a consistent pattern for authoring design-system-grade primitives in the astro workspace. ## Core Features & Use Cases - Static-first primitives: Guides authoring stateless .astro components (Button, Card, Pill) with zero JavaScript, reserving .tsx React islands only for genuinely interactive cases. - CVA variant recipes: Standardizes class-variance-authority recipes in frontmatter so one primitive covers all variants instead of forked subcomponents like PrimaryButton. - Token-based styling: Enforces Tailwind utilities mapped to shared CSS variables from tokens.css, with a registry of bad practices (inline hex colors, client:load overuse, cross-app imports) to avoid. - Use Case: When adding a new Badge component to the landing page, follow the checklist to ship a single static Badge.astro with CVA tone variants and slot-based content instead of a hydrated React component. ## Quick Start Ask the agent to create a new astro primitive component, for example a Pill with info, success, and warning tone variants, following the registry patterns.

Frequently Asked Questions about primitive (astro)

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a reusable Button component in Astro?

Author a single Button.astro file with a class-variance-authority recipe in the frontmatter defining variant and size options, then emit the computed class on the root element. Render an anchor tag when href is provided and forward content with a slot.

When should an Astro component be a React island instead of static?

Use a .tsx React island only when the component needs controlled state, reads from window or document, handles state-changing events, or mounts a portal or popover. Everything else should stay as a static .astro file shipping zero JavaScript.

How do I use class-variance-authority in an Astro component?

Define the cva recipe inside the .astro frontmatter with variants and defaultVariants, derive props with VariantProps, and apply class={variants({ variant, size })} on the rendered element. This mirrors the React primitive pattern exactly.

Can Astro primitives import components from the React app workspace?

No. Each app workspace is independent and only design tokens are shared via @codm/app-ui. Recreate the primitive locally in packages/app/astro/src/components and consume tokens.css for styling.

Why avoid client:load on interactive Astro components?

client:load hydrates eagerly and delays Largest Contentful Paint. Prefer static rendering by default, and use client:visible for interactive primitives so hydration happens only when the component enters the viewport.