tailwind-helpers
GitHub提供 Tailwind CSS 响应式布局、暗色模式、间距规范及 shadcn/ui 集成指南,辅助生成高质量前端样式代码。
Trigger Scenarios
Install
npx skills add Amery2010/open-builder --skill tailwind-helpers -g -y
SKILL.md
Frontmatter
{
"name": "tailwind-helpers",
"tags": [
"tailwind",
"css",
"ui"
],
"version": "1.0.0",
"description": "Production-grade Tailwind CSS patterns for responsive layouts, dark mode, spacing scales, shadcn integration, and accessible color usage. Load before writing any styled UI."
}
Tailwind Helpers
Responsive breakpoints
Tailwind's default breakpoints, in order:
| Prefix | Min width | Typical use |
|---|---|---|
sm: |
640px | large phones / portrait |
md: |
768px | tablets |
lg: |
1024px | desktops |
xl: |
1280px | wide desktops |
2xl: |
1536px | ultra-wide |
Default to mobile-first: write base styles for the smallest screen, then add sm: md: lg: overrides as the layout opens up. Do not write lg: then "undo" it at sm:.
Common patterns:
- One-up to two-up:
grid grid-cols-1 md:grid-cols-2 - Stack to row:
flex flex-col md:flex-row gap-4 - Hidden on mobile:
hidden md:block - Hidden on desktop:
md:hidden - Adaptive padding:
p-4 md:p-6 lg:p-8
Dark mode
Use the dark: variant. Make sure the surrounding scope toggles via class (the standard shadcn pattern) and that text/background tokens come in pairs.
<div class="bg-background text-foreground border border-border">
Avoid dark:bg-zinc-900 style ad-hoc colors — prefer the semantic tokens (background, foreground, muted, muted-foreground, accent, border, primary, destructive). They are already dark-mode aware via CSS variables.
Inline literal colors should be reserved for status accents that are intentionally constant (e.g. amber warning banner, green success).
Spacing scale
The 1 step is 0.25rem (4px). Stick to the scale; do not invent arbitrary values unless you have a strict design constraint.
| Class | px | Use |
|---|---|---|
0.5 |
2 | hairline |
1 |
4 | between very tight inline elements |
2 |
8 | between tight elements |
3 |
12 | between related items |
4 |
16 | default gap inside a card |
6 |
24 | between sections inside a page |
8 |
32 | between major page regions |
12 |
48 | top-level page padding |
Use gap-* on flex/grid for element spacing. Reserve space-y-* / space-x-* for non-flex stacks; they don't compose with wrapping flex.
shadcn/ui conventions
- Always pass
classNamethrough — never hard-setButton/Inputstyles inline that override the variant. Override viaclassName+cn()from@/lib/utils. - For sizing variants stick to shadcn's:
size="sm",size="lg",size="icon". Custom sizes should use thedefaultvariant + className. - Combine multiple conditional classes with
cn()(clsx + tailwind-merge):cn("base", isActive && "ring-2", className). Do not concatenate raw strings.
Layout primitives
flex items-center justify-between gap-3 // header bar
flex flex-col gap-2 // vertical list
grid grid-cols-[auto_1fr_auto] items-center // icon + title + action row
absolute inset-0 // overlay fill
Focus and accessibility
- Every interactive element gets a visible focus ring. shadcn
Buttonalready does this — do not stripfocus-visible:*classes. - Use
aria-pressedfor toggle buttons,aria-expandedfor disclosure buttons. - Tap targets on touch should be at least
h-9 w-9(36px); 44px is the WCAG goal. - Color contrast:
text-muted-foregroundis intentionally low-contrast; never put critical text on it.
Common mistakes
- Mixing
space-x-*withgap-*— pick one. w-fullon a flex item where you actually wantedflex-1.min-h-screeneverywhere — usuallymin-h-0+ flex parents is what you actually want.- Hardcoded colors (
bg-gray-100) in a component that lives in a dark-mode app. - Padding inside a button via
pl-/pr-instead of using shadcn'ssizevariant.
Version History
- fea7528 Current 2026-08-28 16:15


