Skip to main content

React Prompt to Build a Design System Component Library

Build a React design system with tokens, primitives, compound components, accessibility, Storybook docs and npm packaging.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt builds a React design system library so a product can stay visually consistent across many screens without copy-pasting components. For each component it generates a TypeScript props interface, a compound-component pattern where appropriate, styling driven by design tokens, WAI-ARIA compliance with keyboard navigation, defined variants, animations, Storybook stories, and unit tests. It also adds a theme provider, dark mode, CSS custom properties for tokens, tree-shakeable packaging, and a Figma-aligned token file.

The variables name the system and its surface. [library_name] is the package, and [components] lists what to build — Button, Input, Modal, DataTable, and so on. [styling_approach] sets how components are styled (Tailwind with class-variance-authority), [variants] defines the size and intent options each component exposes, [animation_lib] powers motion, and [bundler] packages it for tree-shaking. The load-bearing ideas are design tokens and compound-component patterns, which are what let the system scale, and WAI-ARIA compliance treated as non-negotiable rather than optional. Storybook plus tree-shakeable packaging is what turns the result into something other teams can actually adopt.

When to use it

  • Building a shared UI library so screens stay consistent without duplicated components
  • Establishing design tokens that map to a Figma source of truth
  • Creating accessible primitives with proper keyboard navigation from the start
  • Standardizing component variants (sizes, intents) across a product
  • Packaging components for tree-shaking so consumers only bundle what they import
  • Documenting components in Storybook so other teams can adopt them

Example output

You get a component per entry in [components], each with a typed props interface, compound subcomponents where it fits, [styling_approach] styling tied to design tokens, the [variants] you specified, animations via [animation_lib], WAI-ARIA roles and keyboard handling, a Storybook story with controls, and a unit test. Supporting pieces include a theme provider, dark mode through CSS custom properties, a [bundler] setup for tree-shaking, and a Figma-aligned token file. The output reads as an adoptable package, not a folder of loose components.

Pro tips

  • Keep [components] to genuine primitives and a few composites; building a kitchen-sink list at once dilutes quality across every component
  • Define [variants] deliberately (size sm/md/lg, variant primary/secondary/ghost/destructive) so class-variance-authority generates a clean, predictable API
  • Treat WAI-ARIA and keyboard navigation as acceptance criteria, not nice-to-haves — accessibility retrofitted later is far more expensive
  • Drive everything from the token file so dark mode and theming flow from CSS custom properties rather than scattered overrides
  • Verify the [bundler] output actually tree-shakes; a barrel export done wrong can pull the whole library into every consumer
  • Use the Storybook stories as the contract with other teams, and keep them current when a component's props change

Frequently Asked Questions

Why are design tokens central to this prompt?
Tokens for colors, spacing, and typography give every component a single source of styling truth, so theming and dark mode flow from one place. They are what let the design system scale across many screens without scattered, inconsistent overrides.
Is accessibility actually enforced?
Yes, WAI-ARIA compliance and keyboard navigation are required for each component rather than optional. Treating accessibility as acceptance criteria from the start is far cheaper than retrofitting it, though you should still test with real assistive technology.
What is the compound component pattern used for?
It lets composite components like Tabs or Accordion expose subcomponents that share state implicitly, giving consumers a flexible, readable API. The prompt applies it where appropriate so complex components stay composable rather than monolithic prop bags.
Will the library tree-shake properly?
The prompt packages with a bundler configured for tree-shaking so consumers bundle only what they import. You should verify the output, because a misconfigured barrel export can defeat tree-shaking and pull the entire library into every app that uses one component.
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 React & Next.js Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

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

[email protected]

✓ 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