Typography & Spacing Enforcer Skill
This Skill ensures all UI components follow the project's Typography system and modern spacing conventions for consistent design.
When to Activate
- After creating new UI components
- When refactoring existing components
- During code reviews before PR approval
- When migrating legacy code to new standards
What to Check
Typography Violations
Raw HTML Headings:
- ❌
<h1>, <h2>, <h3>, <h4>
- ✅
Typography.H1, Typography.H2, Typography.H3, Typography.H4
Raw Paragraph Tags:
- ❌
<p className="text-lg">...</p>
- ✅
Typography.TextLg, Typography.Text, Typography.TextSm
Incorrect Heading Hierarchy:
- Multiple H1 elements on a page
- Skipping heading levels (H1 → H3)
- Using wrong semantic level for content
Missing Semantic Colors:
- Components should use HeroUI semantic colors:
text-foreground (primary text)
text-default-900 (strong emphasis)
text-default-600 (secondary text)
text-muted-foreground (metadata)
Spacing Violations
Space-y Utilities (Legacy Pattern):
- ❌
<div className="space-y-4">
- ✅
<div className="flex flex-col gap-4">
Margin-Top on Siblings:
- ❌
<CardComponent className="mt-4" />
- ✅ Parent uses
flex flex-col gap-4
Odd Gap Values:
- ❌
gap-1, gap-3, gap-5 (without justification)
- ✅
gap-2, gap-4, gap-6, gap-8
Redundant Height/Width (Tailwind v3.4+):
- ❌
<div className="h-4 w-4"> (equal dimensions)
- ✅
<div className="size-4"> (use size-* utility)
- ⚠️ Exception: Different dimensions still use
h-* and w-* (e.g., h-4 w-6)
Exception: mt-* is acceptable ONLY for icon alignment with text (e.g., <Icon className="mt-1" />)
Actions Performed
- Scan Component Files: Use Grep to find violations
- Report Violations: List each issue with file:line reference
- Provide Auto-Fix Suggestions: Show before/after code examples
- Check Typography Imports: Ensure
Typography is imported from @web/components/typography
- Check Size Utility Usage: Detect
h-* w-* patterns with equal values and suggest size-*
Example Output
Typography & Spacing Violations Found:
src/app/(dashboard)/coe/_components/category-card.tsx:15
❌ <h3 className="text-2xl">Category A</h3>
✅ <Typography.H3>Category A</Typography.H3>
src/components/charts/trend-chart.tsx:42
❌ <div className="space-y-4">
✅ <div className="flex flex-col gap-4">
src/app/blog/_components/post-list.tsx:28
❌ <PostCard className="mt-6" />
✅ Parent should use: <div className="flex flex-col gap-6">
src/components/icons/search-icon.tsx:8
❌ <svg className="h-4 w-4">
✅ <svg className="size-4">
Spacing Scale Reference
gap-2 (0.5rem / 8px) - Small spacing, compact lists
gap-4 (1rem / 16px) - Standard spacing, most common
gap-6 (1.5rem / 24px) - Medium spacing, section groups
gap-8 (2rem / 32px) - Large spacing, major sections
Typography Components Reference
Headings:
Typography.H1 - Page titles (text-4xl, font-semibold)
Typography.H2 - Section titles (text-3xl, font-semibold)
Typography.H3 - Card titles (text-2xl, font-medium)
Typography.H4 - Nested sections (text-xl, font-medium)
Body Text:
Typography.TextLg - Lead paragraphs (text-lg)
Typography.Text - Standard body (text-base)
Typography.TextSm - Secondary info (text-sm)
UI Labels:
Typography.Label - Form labels, tabs (font-medium, text-sm)
Typography.Caption - Metadata, timestamps (text-xs)
Tools Used
- Grep: Search for violation patterns across component files
- Read: Examine specific files for detailed analysis
- Glob: Find all component files in specific directories
Target Directories
src/app/**/_components/ (co-located components)
src/components/ (shared components)
- Exclude:
src/components/ui/ (shadcn/ui - DO NOT MODIFY)
1---2name: typography-spacing-enforcer3description: Enforce Typography system and modern spacing conventions. Use when implementing new UI components to ensure design consistency with project standards.4---5
6# Typography & Spacing Enforcer Skill
7
8This Skill ensures all UI components follow the project's Typography system and modern spacing conventions for consistent design.
9
10## When to Activate
11
12- After creating new UI components
13- When refactoring existing components
14- During code reviews before PR approval
15- When migrating legacy code to new standards
16
17## What to Check
18
19### Typography Violations
20
21**Raw HTML Headings**:
22- ❌ `<h1>`, `<h2>`, `<h3>`, `<h4>`
23- ✅ `Typography.H1`, `Typography.H2`, `Typography.H3`, `Typography.H4`
24
25**Raw Paragraph Tags**:
26- ❌ `<p className="text-lg">...</p>`
27- ✅ `Typography.TextLg`, `Typography.Text`, `Typography.TextSm`
28
29**Incorrect Heading Hierarchy**:
30- Multiple H1 elements on a page
31- Skipping heading levels (H1 → H3)
32- Using wrong semantic level for content
33
34**Missing Semantic Colors**:
35- Components should use HeroUI semantic colors:
36 - `text-foreground` (primary text)
37 - `text-default-900` (strong emphasis)
38 - `text-default-600` (secondary text)
39 - `text-muted-foreground` (metadata)
40
41### Spacing Violations
42
43**Space-y Utilities** (Legacy Pattern):
44- ❌ `<div className="space-y-4">`
45- ✅ `<div className="flex flex-col gap-4">`
46
47**Margin-Top on Siblings**:
48- ❌ `<CardComponent className="mt-4" />`
49- ✅ Parent uses `flex flex-col gap-4`
50
51**Odd Gap Values**:
52- ❌ `gap-1`, `gap-3`, `gap-5` (without justification)
53- ✅ `gap-2`, `gap-4`, `gap-6`, `gap-8`
54
55**Redundant Height/Width** (Tailwind v3.4+):
56- ❌ `<div className="h-4 w-4">` (equal dimensions)
57- ✅ `<div className="size-4">` (use size-* utility)
58- ⚠️ Exception: Different dimensions still use `h-*` and `w-*` (e.g., `h-4 w-6`)
59
60**Exception**: `mt-*` is acceptable ONLY for icon alignment with text (e.g., `<Icon className="mt-1" />`)
61
62## Actions Performed
63
641. **Scan Component Files**: Use Grep to find violations
652. **Report Violations**: List each issue with file:line reference
663. **Provide Auto-Fix Suggestions**: Show before/after code examples
674. **Check Typography Imports**: Ensure `Typography` is imported from `@web/components/typography`
685. **Check Size Utility Usage**: Detect `h-* w-*` patterns with equal values and suggest `size-*`
69
70## Example Output
71
72```
73Typography & Spacing Violations Found:
74
75src/app/(dashboard)/coe/_components/category-card.tsx:15
76❌ <h3 className="text-2xl">Category A</h3>
77✅ <Typography.H3>Category A</Typography.H3>
78
79src/components/charts/trend-chart.tsx:42
80❌ <div className="space-y-4">
81✅ <div className="flex flex-col gap-4">
82
83src/app/blog/_components/post-list.tsx:28
84❌ <PostCard className="mt-6" />
85✅ Parent should use: <div className="flex flex-col gap-6">
86
87src/components/icons/search-icon.tsx:8
88❌ <svg className="h-4 w-4">
89✅ <svg className="size-4">
90```
91
92## Spacing Scale Reference
93
94- `gap-2` (0.5rem / 8px) - Small spacing, compact lists
95- `gap-4` (1rem / 16px) - Standard spacing, most common
96- `gap-6` (1.5rem / 24px) - Medium spacing, section groups
97- `gap-8` (2rem / 32px) - Large spacing, major sections
98
99## Typography Components Reference
100
101**Headings**:
102- `Typography.H1` - Page titles (text-4xl, font-semibold)
103- `Typography.H2` - Section titles (text-3xl, font-semibold)
104- `Typography.H3` - Card titles (text-2xl, font-medium)
105- `Typography.H4` - Nested sections (text-xl, font-medium)
106
107**Body Text**:
108- `Typography.TextLg` - Lead paragraphs (text-lg)
109- `Typography.Text` - Standard body (text-base)
110- `Typography.TextSm` - Secondary info (text-sm)
111
112**UI Labels**:
113- `Typography.Label` - Form labels, tabs (font-medium, text-sm)
114- `Typography.Caption` - Metadata, timestamps (text-xs)
115
116## Tools Used
117
118- **Grep**: Search for violation patterns across component files
119- **Read**: Examine specific files for detailed analysis
120- **Glob**: Find all component files in specific directories
121
122## Target Directories
123
124- `src/app/**/_components/` (co-located components)
125- `src/components/` (shared components)
126- Exclude: `src/components/ui/` (shadcn/ui - DO NOT MODIFY)