Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/miklosme/css-to-tailwind

Convert plain CSS to TailwindCSS classes. Demo: https://transform.tools/css-to-tailwind
https://github.com/miklosme/css-to-tailwind

tailwind tailwindcss

Last synced: about 1 month ago
JSON representation

Convert plain CSS to TailwindCSS classes. Demo: https://transform.tools/css-to-tailwind

Awesome Lists containing this project

README

        

# CSS To Tailwind

Convert CSS to [TailwindCSS](https://github.com/tailwindlabs/tailwindcss) classes.

# Demo: [transform.tools/css-to-tailwind](https://transform.tools/css-to-tailwind)

## Usage

`npx css-to-tailwind ".logo { margin-bottom: 1.6rem; min-height: 4rem; display: flex; justify-content: center; }"`

The package also offers a Node API. Use that if you need custom TailwindCSS configuration. I don't have time to document it, but reading these two PRs should clarify everything:
1. [Introducing css-to-tailwind to transform.tools](https://github.com/ritz078/transform/pull/235)
2. [Adding custom config support to transform.tools](https://github.com/ritz078/transform/pull/243)

TailwindCSS can't run in a browser, because it depends on Node APIs. However this project can, by using the entry `css-to-tailwind/browser`. In this case, run TailwindCSS on the server side, if you want to use a custom Tailwind config. See the second PR above for details.

## Output

`Array<{ selector: string, tailwind: string, missing: Array>}>`

- `selector`: The selector used in the input CSS.
- `tailwind`: List of TailwindCSS classes in a single string, separated by a space.
- `missing`: The properties that can't be converted, will appear as an array of tuples.

```
[
{
"selector": ".logo",
"tailwind": "flex justify-center mb-6",
"missing": [
[
"min-height",
"4rem"
]
]
}
]
```

## License

MIT