react-classlist

Organize long React className attributes into semantic multi-line groups.

5|Updated Feb 3, 2024
One-click install
npx skills add https://github.com/ahkohd/dotfiles --skill react-classlist
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: react-classlist
Source: https://github.com/ahkohd/dotfiles/tree/main/claude/.claude/skills/react-classlist
Command: npx skills add https://github.com/ahkohd/dotfiles --skill react-classlist

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps organize long or disorganized className attributes in React components into semantic groups, improving readability and maintainability.

Core Features & Use Cases

  • Automatic grouping by category order: Layout, Spacing, Sizing, Display, Typography, Colors & backgrounds, Borders & effects, Positioning, Transitions, and responsive variants.
  • Support for cn() or className: Use cn() if already imported, otherwise standard className.
  • Consistent multi-line formatting: Breaks lines so each group is readable and cohesive.
  • Use Case: Refactor a messy className like "flex items-center justify-between w-full md:w-auto p-2 md:p-4 bg-white" into a clean, grouped, multi-line form.

Quick Start

Refactor a long className in a React component by applying this Skill to the file, then replace the original string with the formatted className using cn().

Frequently Asked Questions about react-classlist

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

FAQPage Schema
How do I organize long className strings in React?

Organize long className attributes by grouping them semantically—layout, spacing, sizing, display, typography, colors, borders, positioning, and transitions—then break into multiple lines with each group under ~80 characters. Use cn() if already imported, otherwise className, to keep code readable and maintainable.

When should I refactor messy React classNames?

Refactor classNames when a single line exceeds 80–100 characters, when cn() or classList() usage is scattered across components, or during code reviews. Semantic grouping improves readability and makes future changes easier without altering functionality.

Can I use cn() and className interchangeably for grouped styles?

Yes. Use cn() if it's already imported in your component; otherwise use className. Both support multi-line semantic grouping. The choice depends on whether your project already uses a classnames utility, not on the grouping strategy.

What's the correct order for grouping Tailwind or utility classes?

Group in this order: layout (flex, grid), spacing (margin, padding), sizing (width, height), display properties, typography, colors and backgrounds, borders and effects, positioning, transitions, then responsive variants (md:, lg:). This order improves scannability and consistency.

How do I handle responsive variants when organizing classNames?

Keep responsive variants (md:, lg:, etc.) grouped at the end after all base utility classes. Break lines so each group—base utilities and responsive prefixes together—stays under ~80 characters, maintaining semantic clarity across all breakpoints.