Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/ironmanvim/tailwindcssx

Classify TailwindCSS classnames
https://github.com/ironmanvim/tailwindcssx

css tailwind tailwindcss

Last synced: 28 days ago
JSON representation

Classify TailwindCSS classnames

Awesome Lists containing this project

README

        

# TailwindCSSX

Group TailwindCSS classnames

Tried of managing ungrouped tailwindcss classnames.

Use TailwindCSSX to group tailwindcss classnames.

## Usage
Using Array

```jsx
import twx from "tailwindcssx";

export default const App = () => {
return (


Group classnames

)
}

/*
result classname: 'border-red-100 text-sm'
*/
```

You can use array in an array

```jsx
import twx from "tailwindcssx";

export default const App = () => {
return (


Multiple Groups

)
}

/*
result classname: 'border-red-500 text-sm text-red-400 font-semibold'
*/
```

You can disable or enable groups with variables
```jsx
import twx from "tailwindcssx";

export default const App = ({theme}) => {
return (


Multiple Groups with conditions.

)
}

/*
result classname:
if theme === 'red': 'font-semibold border-red-500 text-sm'
if theme === 'blue: 'font-semibold border-blue-500 text-md'
*/
```

You can have separate group for each variant using object syntax
```jsx
import twx from "tailwindcssx";

export default const App = () => {
return (


Object Grouping

)
}

/*
result classname: 'border-red-500 hover:border-blue-500 md:text-red-600 md:hover:text-green-600 md:hover:text-sm'
*/
```

If you have a custom separator other than default separator ':'.

```jsx
// twx.js
import twx from "tailwindcssx";

export default (classNames) => {
return twx(classNames, '', '_'); // last argument is the separator
}
```

```jsx
import twx from "./twx";

export default const App = () => {
return (


With Custom Separator

)
}

/*
result classname: 'border-red-500 hover_border-blue-500 md_text-red-600 md_hover_text-green-600 md_hover_text-sm'
*/
```