home / skills / hoangnguyen0403 / agent-skills-standard / styling
This skill helps optimize Next.js styling and UI performance by enforcing zero-runtime CSS with Tailwind, RSC compatibility, and robust font handling.
npx playbooks add skill hoangnguyen0403/agent-skills-standard --skill stylingReview the files below or copy the command above to add this skill to your agents.
---
name: Next.js Styling & UI Performance
description: Zero-runtime CSS strategies (Tailwind) and RSC compatibility.
metadata:
labels: [nextjs, styling, tailwind, css]
triggers:
files: ['**/*.css', 'tailwind.config.ts', '**/components/ui/*.tsx']
keywords: [tailwind, css modules, styled-components, clsx, cn]
---
# Styling & UI Performance
## **Priority: P1 (HIGH)**
Prioritize **Zero-Runtime** CSS for Server Components.
## Library Selection
| Library | Verdict | Reason |
| :------------------------- | :----------------- | :------------------------------------------------- |
| **Tailwind / shadcn** | **Preferred (P1)** | Zero-runtime, RSC compatible. Best for App Router. |
| **CSS Modules** | **Recommended** | Scoped, zero-runtime. |
| **MUI / Chakra (Runtime)** | **Avoid** | Forces `use client` widely. Degrades performance. |
## Patterns
1. **Dynamic Classes**: Use `clsx` + `tailwind-merge` (`cn` utility).
- _Reference_: [Dynamic Classes & Button Example](references/implementation.md)
2. **Font Optimization**: Use `next/font` to prevent Cumulative Layout Shift (CLS).
- _Reference_: [Font Setup](references/implementation.md)
3. **CLS Prevention**: Always specify `width`/`height` on images.
This skill documents practical strategies for Styling & UI Performance in Next.js with a focus on zero-runtime CSS and React Server Component (RSC) compatibility. It guides library choices, component patterns, and performance safeguards to keep server-rendered pages fast and stable. The guidance prioritizes App Router workflows and reducing client-side runtime overhead.
The skill inspects styling choices and runtime behavior to recommend zero-runtime CSS solutions such as Tailwind and shadcn for server components. It flags libraries that force client bundles (for example component libraries that require `use client`) and suggests alternatives like CSS Modules or utility-first approaches. It also enforces specific patterns for dynamic class composition, font loading, and image dimensions to prevent layout shifts.
Why avoid MUI or Chakra in server components?
Many such libraries rely on runtime styling and require `use client`, which forces client-side bundles and negates server rendering performance benefits.
Is Tailwind truly zero-runtime?
When used with static utility classes and build-time processing, Tailwind adds no runtime overhead; combine with RSC to keep styles server-side.