shadcn + Tailwind UI
Shared communication
Apply TW plain-language and guidance rules to user-facing work. Explain terms in context; preserve the user's chosen 新人/入门/熟练/老手 level without inferred changes. 新人 and 入门 receive detailed explanations; every level receives needed and bug explanations unless the user explicitly waives that scope. Soul and prose modes never disable this baseline. Load the shared reference for task entry, level management, or explanation decisions.
Before UI writes, use $consult-tavernweave-library with the shadcn-tailwind-ui route to load A0, responsive/CSS guides, and candidate design/motion references. Selecting a library or visual direction does not authorize dependency installation or overwrite existing configuration.
Use this skill for implementation work inside an existing React codebase. Preserve the project's framework, package manager, component conventions, tokens, and installed shadcn components before introducing anything new.
Scope
- React, Vite, and Next.js applications.
- shadcn/ui components backed by Radix UI primitives.
- Tailwind CSS utilities, semantic tokens, responsive layout, dark mode, and reduced motion.
- Product UI such as forms, dialogs, navigation, tables, settings, dashboards, and empty/error/loading states.
This skill does not provide fonts, images, canvas design, poster generation, or third-party component source. Read provenance.md before redistributing this skill.
Workflow
- Inspect the project before changing it:
- Read
package.json, the lockfile, components.json, the CSS entry point, and existing UI components.
- Detect the React framework, Tailwind major version, path aliases, icon library, form stack, and package manager.
- Check existing user changes and avoid replacing configuration or generated components blindly.
- Reuse the current system:
- Prefer an installed shadcn component over a parallel custom primitive.
- Reuse semantic colors, spacing, radius, typography, and motion tokens.
- Extend a component locally only when the behavior or repeated variant requires it.
- Implement structure before decoration:
- Use semantic HTML and a logical heading order.
- Provide labels, descriptions, error associations, visible focus, keyboard operation, and stable loading/error/empty states.
- Compose dialogs, menus, tabs, selects, and popovers from Radix-backed primitives instead of recreating focus management.
- Style mobile-first:
- Start with the smallest supported viewport, then add a small number of breakpoint overrides.
- Use wrapping,
min-w-0, overflow rules, and content constraints deliberately.
- Support light/dark themes, 200% zoom, reduced motion, long text, and touch targets.
- Validate in the real project:
- Run the project's typecheck, lint, tests, and build at the smallest useful scope.
- Exercise keyboard-only navigation, focus return, form errors, responsive breakpoints, dark mode, and reduced motion.
- Inspect the rendered DOM and computed layout; a successful build alone does not prove UI behavior.
Component Rules
- Use
Button for actions and links for navigation; do not attach click behavior to plain div elements.
- Every input needs an accessible name. Associate errors and descriptions with the input that owns them.
- Icon-only controls require an accessible label and a visible focus state.
- Destructive actions require clear wording and confirmation proportional to impact.
- Dialogs must have a title, focus containment, Escape handling, and focus return to the trigger.
- Prefer semantic token classes such as
bg-background, text-foreground, and text-muted-foreground over scattered literal colors.
- Avoid runtime-built Tailwind class fragments that the compiler cannot discover. Use complete class names or an explicit safelist.
- Respect
prefers-reduced-motion; motion must not be the only way to communicate state.
Tailwind Configuration Safety
Prefer the project's existing configuration. Tailwind versions differ: use the installed version's official documentation before deciding between a JavaScript/TypeScript config and CSS-first @theme customization.
For projects that intentionally use a config file, scripts/generate_tailwind_config.py is a guarded helper:
# Default TypeScript format; dry run prints the proposed file and writes nothing.
python scripts/generate_tailwind_config.py --framework react --format typescript --colors brand:#2563eb
# ESM JavaScript: tailwind.config.js with export default.
python scripts/generate_tailwind_config.py --framework nextjs --format esm --write
# CommonJS: tailwind.config.cjs with module.exports; explicitly replace an existing file.
python scripts/generate_tailwind_config.py --framework nextjs --format commonjs --force
Choose typescript for tailwind.config.ts, esm for tailwind.config.js, or commonjs for tailwind.config.cjs. Match the project's existing module mode; do not change package.json just to fit the generator. The selected format controls both the default extension and export syntax. --force is the only overwrite path. Review the printed proposal and preserve project-specific content paths, plugins, and tokens before using it.
Installing shadcn Components
Treat the shadcn CLI as a project mutation:
- Confirm
components.json and the package manager.
- Inspect whether the requested component already exists or has local edits.
- Pin or confirm the CLI version appropriate for the project.
- Run the smallest
add command; do not use --all by default.
- Review the generated diff and run the project checks.
Never overwrite a locally modified component without explicit user authorization.
References
- react-ui-checklist.md: compact implementation and acceptance checklist.
- provenance.md: source and licensing boundary for this clean derivative.
1---2name: shadcn-tailwind-ui3description: Build, restyle, or review accessible React interfaces that use shadcn/ui, Radix UI primitives, and Tailwind CSS. Use for component composition, responsive layouts, semantic design tokens, dark mode, forms, dialogs, tables, keyboard interaction, and safe Tailwind configuration in React, Vite, or Next.js projects. Do not use for canvas art, posters, font bundles, non-React frameworks, or general brand design.4---56# shadcn + Tailwind UI78<!-- tw-guidance-entry:begin -->9## Shared communication1011Apply [TW plain-language and guidance rules](../consult-tavernweave-library/references/communication-and-guidance.md) to user-facing work. Explain terms in context; preserve the user's chosen 新人/入门/熟练/老手 level without inferred changes. 新人 and 入门 receive detailed explanations; every level receives needed and bug explanations unless the user explicitly waives that scope. Soul and prose modes never disable this baseline. Load the shared reference for task entry, level management, or explanation decisions.12<!-- tw-guidance-entry:end -->1314Before UI writes, use `$consult-tavernweave-library` with the `shadcn-tailwind-ui` route to load A0, responsive/CSS guides, and candidate design/motion references. Selecting a library or visual direction does not authorize dependency installation or overwrite existing configuration.1516Use this skill for implementation work inside an existing React codebase. Preserve the project's framework, package manager, component conventions, tokens, and installed shadcn components before introducing anything new.1718## Scope1920- React, Vite, and Next.js applications.21- shadcn/ui components backed by Radix UI primitives.22- Tailwind CSS utilities, semantic tokens, responsive layout, dark mode, and reduced motion.23- Product UI such as forms, dialogs, navigation, tables, settings, dashboards, and empty/error/loading states.2425This skill does not provide fonts, images, canvas design, poster generation, or third-party component source. Read [provenance.md](references/provenance.md) before redistributing this skill.2627## Workflow28291. Inspect the project before changing it:30 - Read `package.json`, the lockfile, `components.json`, the CSS entry point, and existing UI components.31 - Detect the React framework, Tailwind major version, path aliases, icon library, form stack, and package manager.32 - Check existing user changes and avoid replacing configuration or generated components blindly.332. Reuse the current system:34 - Prefer an installed shadcn component over a parallel custom primitive.35 - Reuse semantic colors, spacing, radius, typography, and motion tokens.36 - Extend a component locally only when the behavior or repeated variant requires it.373. Implement structure before decoration:38 - Use semantic HTML and a logical heading order.39 - Provide labels, descriptions, error associations, visible focus, keyboard operation, and stable loading/error/empty states.40 - Compose dialogs, menus, tabs, selects, and popovers from Radix-backed primitives instead of recreating focus management.414. Style mobile-first:42 - Start with the smallest supported viewport, then add a small number of breakpoint overrides.43 - Use wrapping, `min-w-0`, overflow rules, and content constraints deliberately.44 - Support light/dark themes, 200% zoom, reduced motion, long text, and touch targets.455. Validate in the real project:46 - Run the project's typecheck, lint, tests, and build at the smallest useful scope.47 - Exercise keyboard-only navigation, focus return, form errors, responsive breakpoints, dark mode, and reduced motion.48 - Inspect the rendered DOM and computed layout; a successful build alone does not prove UI behavior.4950## Component Rules5152- Use `Button` for actions and links for navigation; do not attach click behavior to plain `div` elements.53- Every input needs an accessible name. Associate errors and descriptions with the input that owns them.54- Icon-only controls require an accessible label and a visible focus state.55- Destructive actions require clear wording and confirmation proportional to impact.56- Dialogs must have a title, focus containment, Escape handling, and focus return to the trigger.57- Prefer semantic token classes such as `bg-background`, `text-foreground`, and `text-muted-foreground` over scattered literal colors.58- Avoid runtime-built Tailwind class fragments that the compiler cannot discover. Use complete class names or an explicit safelist.59- Respect `prefers-reduced-motion`; motion must not be the only way to communicate state.6061## Tailwind Configuration Safety6263Prefer the project's existing configuration. Tailwind versions differ: use the installed version's official documentation before deciding between a JavaScript/TypeScript config and CSS-first `@theme` customization.6465For projects that intentionally use a config file, `scripts/generate_tailwind_config.py` is a guarded helper:6667```powershell68# Default TypeScript format; dry run prints the proposed file and writes nothing.69python scripts/generate_tailwind_config.py --framework react --format typescript --colors brand:#2563eb7071# ESM JavaScript: tailwind.config.js with export default.72python scripts/generate_tailwind_config.py --framework nextjs --format esm --write7374# CommonJS: tailwind.config.cjs with module.exports; explicitly replace an existing file.75python scripts/generate_tailwind_config.py --framework nextjs --format commonjs --force76```7778Choose `typescript` for `tailwind.config.ts`, `esm` for `tailwind.config.js`, or `commonjs` for `tailwind.config.cjs`. Match the project's existing module mode; do not change `package.json` just to fit the generator. The selected format controls both the default extension and export syntax. `--force` is the only overwrite path. Review the printed proposal and preserve project-specific content paths, plugins, and tokens before using it.7980## Installing shadcn Components8182Treat the shadcn CLI as a project mutation:83841. Confirm `components.json` and the package manager.852. Inspect whether the requested component already exists or has local edits.863. Pin or confirm the CLI version appropriate for the project.874. Run the smallest `add` command; do not use `--all` by default.885. Review the generated diff and run the project checks.8990Never overwrite a locally modified component without explicit user authorization.9192## References9394- [react-ui-checklist.md](references/react-ui-checklist.md): compact implementation and acceptance checklist.95- [provenance.md](references/provenance.md): source and licensing boundary for this clean derivative.