Skip to main content
skill CX Codex

converting-css-to-tailwind — Claude Code skill: move CSS into

This skill walks a plain CSS file and rewrites its rules as Tailwind utility classes in your markup. Handy when a project moves off hand-written CSS.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add spencerpauly/awesome-cursor-skills --skill converting-css-to-tailwind -a claude-code
Open on GitHub

What converting-css-to-tailwind does

The workflow is linear. The skill reads the CSS file and inventories every rule, finds the markup that references each selector, converts the properties, deletes the rule once it is fully expressed, and finally checks the page for visual regressions. It looks for markup in HTML, JSX, TSX, Vue and Svelte.

A conversion table ships with it: display: flex becomes flex, gap: 16px becomes gap-4, padding: 16px becomes p-4, font-size: 14px becomes text-sm, border-radius: 8px becomes rounded-lg. Media queries turn into sm:, md:, lg:, xl: and 2xl: prefixes, while states map to hover:, focus:, active:, disabled:, first:, last:, odd:, even:, group-hover: and peer-checked:. Transitions and animations have ready classes too, like transition-all duration-200 ease-in-out and animate-spin.

Some CSS stays put. Complex selectors such as .parent > .child + .sibling need the markup restructured, @font-face belongs in a global file, and custom @keyframes plus CSS variables move into tailwind.config.ts. Where a theme exists, the skill prefers semantic classes (bg-primary) over arbitrary hex values. It also tells you not to reach for @apply to rebuild the CSS you are migrating away from.

What it helps with

  • rewrite a legacy stylesheet as Tailwind utilities
  • trace which markup references each CSS selector
  • turn media queries into md: and lg: breakpoints
  • map hover and other states to hover: and focus: prefixes
  • move custom @keyframes and variables into tailwind.config.ts

Example prompts for the agent

  • take styles/card.css and move every rule into Tailwind classes in the markup
  • convert the media queries in layout.css to Tailwind breakpoints
  • check the page still looks the same after the CSS migration and list the selectors that could not be converted

How to install converting-css-to-tailwind

1Skills CLI (Vercel)

npx skills add spencerpauly/awesome-cursor-skills --skill converting-css-to-tailwind -a claude-code

2Manually: put the files in place

~/.claude/skills/converting-css-to-tailwind/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/converting-css-to-tailwind/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about converting-css-to-tailwind

How do I install converting-css-to-tailwind in Claude?

Run npx skills add spencerpauly/awesome-cursor-skills --skill converting-css-to-tailwind -a claude-code. The skill lands in ~/.claude/skills/converting-css-to-tailwind/SKILL.md.

What does converting-css-to-tailwind do?

It reads a CSS file, finds the markup tied to each selector and rewrites the rules as Tailwind utilities, then removes the emptied rules and file. At the end it checks the page for visual regressions.

What can't be converted to utilities?

Complex selectors like .parent > .child + .sibling, @font-face, custom @keyframes and CSS variables. The skill suggests restructuring the markup or moving those into tailwind.config.ts.

Source text

SKILL.md · CC0-1.0
---
name: converting-css-to-tailwind
description: Convert plain CSS stylesheets to Tailwind CSS utility classes. Handles selectors, media queries, pseudo-classes, custom properties, and animations.
user-invocable: true
---

# Converting CSS to Tailwind

Migrate plain CSS files to Tailwind utility classes applied directly in markup.

## Workflow

1. **Read the CSS file** and inventory every rule
2. **Find the corresponding markup** (HTML, JSX, TSX, Vue, Svelte) that references each selector
3. **Convert each rule** using the mapping below
4. **Delete the CSS rule** once all its properties are expressed as utilities
5. **Remove the CSS file** (or import) once it's empty
6. **Verify** the page looks identical — check for visual regressions

## Conversion Reference

### Layout & Box Model

| CSS | Tailwind |
|-----|----------|
| `display: flex` | `flex` |
| `display: grid` | `grid` |
| `display: none` | `hidden` |
| `position: relative` | `relative` |
| `position: absolute` | `absolute` |
| `justify-content: center` | `justify-center` |
| `align-items: center` | `items-center` |
| `gap: 16px` | `gap-4` |
| `width: 100%` | `w-full` |
| `max-width: 768px` | `max-w-3xl` |
| `margin: 0 auto` | `mx-auto` |
| `padding: 16px` | `p-4` |
| `overflow: hidden` | `overflow-hidden` |

### Typography

| CSS | Tailwind |
|-----|----------|
| `font-size: 14px` | `text-sm` |
| `font-weight: 700` | `font-bold` |
| `line-height: 1.5` | `leading-normal` |
| `text-align: center` | `text-center` |
| `text-transform: uppercase` | `uppercase` |
| `color: #333` | `text-[#333]` or a theme color |
| `letter-spacing: 0.05em` | `tracking-wide` |

### Backgrounds & Borders

| CSS | Tailwind |
|-----|----------|
| `background-color: #f5f5f5` | `bg-[#f5f5f5]` or `bg-neutral-100` |
| `border: 1px solid #e5e7eb` | `border border-gray-200` |
| `border-radius: 8px` | `rounded-lg` |
| `box-shadow: 0 1px 3px ...` | `shadow-sm` |

### Responsive — Media Queries

```css
@media (min-width: 768px) { .card { flex-direction: row; } }
```
→ `<div class="flex-col md:flex-row">`

Map breakpoints: `sm:` (640), `md:` (768), `lg:` (1024), `xl:` (1280), `2xl:` (1536)

### Pseudo-classes & States

```css
.btn:hover { background-color: #1d4ed8; }
```
→ `<button class="hover:bg-blue-700">`

Prefixes: `hover:`, `focus:`, `active:`, `disabled:`, `first:`, `last:`, `odd:`, `even:`, `group-hover:`, `peer-checked:`

### Animations & Transitions

```css
transition: all 0.2s ease-in-out;
```
→ `transition-all duration-200 ease-in-out`

```css
@keyframes spin { ... }
animation: spin 1s linear infinite;
```
→ `animate-spin` (built-in) or define in `tailwind.config`

### Custom Properties / Arbitrary Values

For anything without a direct utility, use arbitrary values:
- `w-[calc(100%-2rem)]`
- `grid-cols-[200px_1fr_1fr]`
- `text-[clamp(1rem,2vw,1.5rem)]`

## Handling Remaining CSS

Some things can't be expressed purely as utilities:

- **Complex selectors** (`.parent > .child + .sibling`) — restructure the markup or use `@apply` as a last resort
- **`@font-face`** — keep in a global CSS file or `globals.css`
- **Complex `@keyframes`** — define in `tailwind.config.ts` under `theme.extend.keyframes`
- **CSS variables** — migrate to Tailwind theme values in `tailwind.config.ts`

## Rules

- Prefer semantic Tailwind classes (`bg-primary`) over arbitrary hex values when a theme exists
- Don't use `@apply` to recreate the same CSS you're migrating away from — that defeats the purpose
- Group related utilities logically: layout → spacing → typography → colors → effects
- If a component has 10+ utilities, consider extracting a reusable component rather than a CSS class

© spencerpauly · CC0-1.0 · spencerpauly/awesome-cursor-skills

Similar skills

Everything for Frontend and UI →

From the same set60

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor