Component Standardization Skill
This skill guides the process of replacing custom, "reinvented" UI components and legacy styles with standard library implementations (Ant Design + Tailwind CSS) to ensure consistency and maintainability.
Goal
To eliminate redundant custom styles and components by leveraging a standardized design system based on Ant Design components styled with Tailwind CSS utility classes.
Standardization Rules (The "Gold Standard")
1. Card Component
Pattern: Use Ant Design Card with specific Tailwind classes for borders and shadows.
- DO:
<Card className="rounded-lg shadow-sm border border-gray-200" bordered={false}>
- DON'T:
<Card bordered={false} style={{...}}> or custom div wrappers.
- Rationale: Ensures consistent
gray-200 borders and shadow-sm depth across the app.
2. Layout & Spacing
Pattern: Use Tailwind utility classes for layout and spacing.
- DO:
<div className="p-6 mb-6">, <div className="flex items-center gap-4">
- DON'T:
style={{ padding: 24, marginBottom: 16 }}, <Space style={{...}}>
- Rationale: Reduces runtime JS overhead and enforces the design system's spacing scale.
3. Typography
Pattern: Use native HTML tags with Tailwind classes.
- DO:
<h2 className="text-2xl font-bold text-gray-900">, <p className="text-gray-500">
- DON'T:
<Typography.Title level={2}>, <Typography.Text type="secondary"> (unless strictly necessary for complex text features).
- Rationale: Native tags are semantically correct and Tailwind classes offer more flexible styling control without component overhead.
4. Icons
Pattern: Use lucide-react icons (preferred) or Ant Icons styled with Tailwind.
- DO:
<Bell className="w-4 h-4 text-gray-500" />
- DON'T:
<BellOutlined style={{ fontSize: 16, color: '#666' }} />
- Rationale: Consistent sizing and coloring via utility classes.
5. Theme & Colors
Pattern: Use Tailwind color palette.
- DO:
text-green-500, bg-blue-50, border-red-200
- DON'T:
theme.useToken() (e.g., token.colorSuccess) for static elements.
- Rationale: Decouples components from runtime theme engine for static styles, improving performance and readability.
6. Inputs & Controls
Pattern: Use Ant Design form controls with Tailwind width classes.
- DO:
<Input className="w-64" />, <Select className="w-32" />
- DON'T:
<Input style={{ width: 200 }} />
Workflow
1. Audit & Identify
- specific file or component to refactor.
- Look for
style={{...}} props, token.* usage, and legacy CSS classes.
2. Refactor
- Replace Container: Wrap content in the standard
Card pattern.
- Replace Layouts: Convert
style props to Tailwind classes (padding, margin, flex, grid).
- Replace Text: Convert
Typography components to HTML tags + Tailwind.
- Replace Colors: Map hex codes or tokens to the nearest Tailwind color (e.g.,
#1890ff -> blue-600).
For Extended Wrappers (e.g., AuthButton)
- Action: Rewrite as a lightweight wrapper.
- Implementation:
4. Cleanup
- Delete: Remove the source files of the original custom implementations.
- Update Exports: Clean up
index.ts files to remove dead exports.
- Grep Check: Search the codebase for lingering references to deleted components (e.g.,
grep -r "EnhancedCard" src/).
5. Verification
- Type Check: Run
npx tsc --noEmit to catch broken references immediately.
- Build: Run
npm run build to ensure production build stability.
- Visual Check: Verify key pages (e.g., Login, Dashboard) to ensure styles remain consistent.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: component-standardization3description: Refactors UI components to use Ant Design + Tailwind CSS standards. Enforces specific styling patterns for Cards, Typography, and Layouts to ensure consistency. Invoke when standardizing UI or refactoring legacy styles. Use when this capability is needed.4---56# Component Standardization Skill78This skill guides the process of replacing custom, "reinvented" UI components and legacy styles with standard library implementations (Ant Design + Tailwind CSS) to ensure consistency and maintainability.910## Goal11To eliminate redundant custom styles and components by leveraging a standardized design system based on Ant Design components styled with Tailwind CSS utility classes.1213## Standardization Rules (The "Gold Standard")1415### 1. Card Component16**Pattern**: Use Ant Design `Card` with specific Tailwind classes for borders and shadows.17- **DO**: `<Card className="rounded-lg shadow-sm border border-gray-200" bordered={false}>`18- **DON'T**: `<Card bordered={false} style={{...}}>` or custom `div` wrappers.19- **Rationale**: Ensures consistent `gray-200` borders and `shadow-sm` depth across the app.2021### 2. Layout & Spacing22**Pattern**: Use Tailwind utility classes for layout and spacing.23- **DO**: `<div className="p-6 mb-6">`, `<div className="flex items-center gap-4">`24- **DON'T**: `style={{ padding: 24, marginBottom: 16 }}`, `<Space style={{...}}>`25- **Rationale**: Reduces runtime JS overhead and enforces the design system's spacing scale.2627### 3. Typography28**Pattern**: Use native HTML tags with Tailwind classes.29- **DO**: `<h2 className="text-2xl font-bold text-gray-900">`, `<p className="text-gray-500">`30- **DON'T**: `<Typography.Title level={2}>`, `<Typography.Text type="secondary">` (unless strictly necessary for complex text features).31- **Rationale**: Native tags are semantically correct and Tailwind classes offer more flexible styling control without component overhead.3233### 4. Icons34**Pattern**: Use `lucide-react` icons (preferred) or Ant Icons styled with Tailwind.35- **DO**: `<Bell className="w-4 h-4 text-gray-500" />`36- **DON'T**: `<BellOutlined style={{ fontSize: 16, color: '#666' }} />`37- **Rationale**: Consistent sizing and coloring via utility classes.3839### 5. Theme & Colors40**Pattern**: Use Tailwind color palette.41- **DO**: `text-green-500`, `bg-blue-50`, `border-red-200`42- **DON'T**: `theme.useToken()` (e.g., `token.colorSuccess`) for static elements.43- **Rationale**: Decouples components from runtime theme engine for static styles, improving performance and readability.4445### 6. Inputs & Controls46**Pattern**: Use Ant Design form controls with Tailwind width classes.47- **DO**: `<Input className="w-64" />`, `<Select className="w-32" />`48- **DON'T**: `<Input style={{ width: 200 }} />`4950## Workflow5152### 1. Audit & Identify53- specific file or component to refactor.54- Look for `style={{...}}` props, `token.*` usage, and legacy CSS classes.5556### 2. Refactor57- **Replace Container**: Wrap content in the standard `Card` pattern.58- **Replace Layouts**: Convert `style` props to Tailwind classes (padding, margin, flex, grid).59- **Replace Text**: Convert `Typography` components to HTML tags + Tailwind.60- **Replace Colors**: Map hex codes or tokens to the nearest Tailwind color (e.g., `#1890ff` -> `blue-600`).6162#### For Extended Wrappers (e.g., `AuthButton`)63- **Action**: Rewrite as a lightweight wrapper.64- **Implementation**:65 - Import the standard component.66 - Define an interface that extends the standard props (using `Omit` if necessary).67 - Map custom props (e.g., `variant="outline"`) to standard props (e.g., `type="default"`, `className="border-primary"`).68 - **Ant Design v5 Note**: Map `bodyStyle` / `headStyle` to `styles={{ body: ..., header: ... }}`.69 - Pass through all other props.70 - **Example**:71 ```typescript72 import { Button, type ButtonProps } from 'antd';73 // ... logic to map custom props to Antd props ...74 return <Button {...mappedProps} {...rest} />;75 ```7677### 4. Cleanup78- **Delete**: Remove the source files of the original custom implementations.79- **Update Exports**: Clean up `index.ts` files to remove dead exports.80- **Grep Check**: Search the codebase for lingering references to deleted components (e.g., `grep -r "EnhancedCard" src/`).8182### 5. Verification83- **Type Check**: Run `npx tsc --noEmit` to catch broken references immediately.84- **Build**: Run `npm run build` to ensure production build stability.85- **Visual Check**: Verify key pages (e.g., Login, Dashboard) to ensure styles remain consistent.8687---88> Converted and distributed by [TomeVault](https://tomevault.io/claim/heidsoft) — claim your Tome and manage your conversions.89<!-- tomevault:4.0:skill_md:2026-04-11 -->