Skip to main content

Claude Prompt to Architect a Tailwind Component Library

Design a reusable Tailwind CSS component library with variants, sizes, themes, dark mode and accessibility, ready to extract into an npm package.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
Design a production-grade Tailwind CSS component library for a B2B SaaS application design system.

**Library configuration:**
- Framework: React with TypeScript
- Tailwind version: 3.4+
- Design tokens source: Figma variables exported as JSON
- Dark mode strategy: `class` (toggle-based)
- Component count: 12 components

**For each component, generate:**

1. **Base component with variant system:**
   - Use `cva` (class-variance-authority) or `tailwind-variants` for variant management
   - Variants: `variant` (solid, outline, ghost, link), `size` (xs, sm, md, lg, xl), `color` (primary, secondary, danger, warning, success, neutral)
   - Compound variants for special combinations (e.g., `danger` + `outline` gets red border)
   - Default variants clearly specified

2. **Component list to generate:**
   - **Button** — with loading spinner, icon slots (left/right), button group support
   - **Input** — with label, helper text, error state, prefix/suffix addons, character count
   - **Select** — with search/filter, multi-select, option groups, custom render for options
   - **Modal/Dialog** — with sizes, scroll behavior, nested modal support, focus trap
   - **Toast/Notification** — with auto-dismiss, action buttons, stacking, progress bar
   - **Card** — with header/body/footer slots, hover effects, clickable variant
   - **Badge** — with dot indicator, removable, animated pulse for new items
   - Plus Tabs, Accordion, Dropdown Menu, Avatar, Breadcrumb

3. **Theme system:**
   - CSS custom properties for brand colors mapped to Tailwind config
   - `tailwind.config.js` extension with semantic color tokens (e.g., `--color-surface`, `--color-on-surface`)
   - Dark mode overrides using CSS variables (not separate dark: classes for every element)
   - Typography scale with fluid `clamp()` values
   - Spacing scale rationale document

4. **Accessibility checklist per component:**
   - ARIA roles and attributes
   - Keyboard navigation (Tab, Enter, Escape, Arrow keys as appropriate)
   - Focus visible styles (not just browser default)
   - Screen reader announcements for dynamic content
   - Reduced motion support with `prefers-reduced-motion`

5. **Documentation template:**
   - Props table with types, defaults, and descriptions
   - Live examples for each variant/size combination
   - Do's and Don'ts section with visual examples
   - Storybook story file (CSF3 format) for each component

6. **Tailwind plugin (`tailwind.config.js` additions):**
   - Custom utilities needed by the library
   - Safelist for dynamic class generation
   - Content paths configuration for consumers

Optimize for tree-shaking — each component must be independently importable. Total CSS footprint target: under 15KB gzipped for the full library.

What this prompt does

This prompt designs a production-grade Tailwind CSS component library for the scope you define. You set [library_scope], [framework], [design_tokens], [component_count], [additional_components], and a [css_budget], and it produces a variant system, a list of fully specified components, a theming setup, an accessibility checklist per component, documentation templates, and the Tailwind config additions.

The structure works because a component library lives or dies on consistency, and this prompt enforces it up front. It standardizes on cva or tailwind-variants for variant management, so every component shares the same variant, size, and color axes plus compound variants. Theming runs through CSS custom properties mapped into the Tailwind config rather than scattered dark: classes, and each component carries an ARIA, keyboard, focus, and reduced-motion checklist. The [css_budget] constraint pushes the design toward tree-shakeable, independently importable components.

When to use it

  • A client product needs its own design system and you want the variant and theming architecture locked before writing components.
  • You're standardizing a sprawl of one-off components into a coherent, reusable library.
  • You need consistent dark mode via CSS variables instead of per-element dark: classes.
  • You want an accessibility checklist enforced on every component, not bolted on later.
  • You're planning to extract the library into an npm package and need tree-shaking and a CSS budget.
  • You want Storybook stories and props tables generated alongside each component.

Example output

You get a library blueprint: a variant system built on cva or tailwind-variants with solid/outline/ghost/link variants, xs-through-xl sizes, and semantic colors plus compound variants; full specs for core components (Button, Input, Select, Modal, Toast, Card, Badge) plus your [additional_components]; a theme system with CSS custom properties, a tailwind.config.js extension, and fluid typography; per-component accessibility checklists; documentation and CSF3 Storybook templates; and Tailwind plugin additions with safelist and content paths, targeting your [css_budget].

Pro tips

  • Name your real [framework] (React, Vue, Svelte); the component code and variant utility choice depend on it.
  • Point [design_tokens] at your actual source (Figma export, JSON) so the theme maps to real brand values.
  • Use [additional_components] to extend beyond the core set without losing the shared variant conventions.
  • Treat [css_budget] as a real constraint — it pushes the design toward independently importable, tree-shakeable parts.
  • Generate one component fully first, confirm the variant API feels right, then ask for the rest in the same style.
  • Don't strip the per-component accessibility checklist; it's the part most hand-built libraries skip and regret.

Frequently Asked Questions

Which variant library does it use — cva or tailwind-variants?
It standardizes on `cva` (class-variance-authority) or `tailwind-variants` for managing variants, sizes, colors, and compound variants. Pick one in your request for consistency; both give you a typed, predictable variant API across every component in the library.
How does it handle dark mode?
Through CSS custom properties mapped into the Tailwind config and toggled with a `class` strategy, rather than adding `dark:` variants to every element. This keeps theming centralized and makes it far easier to support multiple brand themes or white-label setups.
Does it work with frameworks other than React?
Yes. Set `[framework]` to React, Vue, Svelte, or another framework, and the component code and documentation adapt. The variant system, theming, and accessibility checklists are framework-agnostic concepts that translate across all of them.
Can the library be tree-shaken into an npm package?
That is an explicit design goal. The prompt optimizes for independently importable components and targets the `[css_budget]` you set, with safelist and content-path config for consumers, so unused components and styles can be dropped from the final bundle.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Frontend Development Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support