component-wrapper-architecture

Wrap shadcn/ui components with 8-bit retro styling using alias-based imports and CVA variants.

2.0k|117|Updated Mar 27, 2025
One-click install
npx skills add https://github.com/TheOrcDev/8bitcn-ui --skill component-wrapper-architecture
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: component-wrapper-architecture
Source: https://github.com/TheOrcDev/8bitcn-ui/tree/main/.claude/skills/component-wrapper-architecture
Command: npx skills add https://github.com/TheOrcDev/8bitcn-ui --skill component-wrapper-architecture

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prescribes a disciplined pattern for wrapping shadcn/ui components with 8-bit retro styling while preserving compatibility with the original base components and APIs, enabling consistent visual theming without breaking existing code.

Core Features & Use Cases

  • Alias-based wrapping: Import the base component and expose a retro-styled alias (e.g., Button as ShadcnButton) to layer visuals without altering the underlying API.
  • Variant-driven styling: Define variants via a utility like class-variance-authority to compose pixel-art themed options and ensure predictable, scalable styling.
  • Safe re-export strategy: Export wrappers alongside original sub-components to maintain a stable public surface while enabling retro customizations.
  • Wrapper patterns across components: Apply the outer-wrapper approach to common components (Button, Card, Dialog) to achieve a unified 8-bit look while preserving behavior.
  • Guiding principles: Use an empty base variant, export a dedicated props interface, and prefer a consistent retro class path for styling.

Quick Start

  • Alias imports to point to the base components as Shadcn equivalents, e.g. import { Button as ShadcnButton } from "@/components/ui/button";
  • Define a minimal variant set using a CVA-style pattern, e.g. export const buttonVariants = cva("", { variants: { font: { normal: "", retro: "retro" }, variant: { default: "bg-foreground" } }, defaultVariants: { variant: "default", size: "default" } });
  • Export a props interface that extends the base component props and VariantProps<typeof buttonVariants>, including optional asChild and a typed ref.
  • Implement the wrapper by applying the retro styling while forwarding all props to the base component.

Frequently Asked Questions about component-wrapper-architecture

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

FAQPage Schema
How do I wrap shadcn/ui components with custom styling without breaking the original API?

Wrapping shadcn/ui components preserves the base API by using alias imports and re-exporting the original alongside a styled wrapper. Import the base component as an alias (e.g., Button as ShadcnButton), define retro variants with CVA, and forward all props to maintain backward compatibility while layering new visuals.

What's the best way to add retro styling to a React component library built with shadcn/ui?

Build a wrapper architecture using class-variance-authority to define pixel-art themed variants, export a props interface extending the base component props, and apply retro classes while forwarding behavior unchanged. This approach scales across Button, Card, Dialog, and other components consistently.

Can I use shadcn/ui components with a design system that requires consistent themed wrappers?

Yes. This pattern is designed for design systems and UI teams building themed component libraries. Use alias-based imports, CVA-driven variants, and a stable re-export strategy to maintain a consistent public surface while enabling retro aesthetics across your entire component set.

How do I maintain component API stability while adding 8-bit retro visual customizations?

Apply an outer-wrapper pattern that separates styling concerns from behavior. Define explicit prop interfaces, use an empty base variant, and prefer a consistent retro class path. This ensures existing code continues working while new themed options remain available.

What's the difference between wrapping components and modifying them directly for styling?

Wrapping preserves the original component's API and enables coexistence of both styled and unstyled versions without breaking dependent code. Direct modification risks compatibility issues. A wrapper architecture supports progressive adoption and backward compatibility in design systems.