Skip to content

ui-devtools/tailwind-utils

Repository files navigation



Utilities to parse and create tailwind classnames

 

Installation

yarn add tailwind-utils

or

npm install tailwind-utils

 

Usage

API choice 1:

import { parse, create, Definition } from 'tailwind-utils'
import theme from './tailwind-theme.js'

const definition:Definition = parse(theme, 'md:w-48');
// { responsiveModifier: 'md', property: 'width', prefix: 'w', value: 48 }

const className:string = create(theme, { responsiveModifier: 'md', pseudoModifier: 'hover', property: 'backgroundColor', value: 'red-500' })
// 'md:hover:bg-48'

API choice 2:

import { ClassName, Definition } from 'tailwind-utils'
import theme from './tailwind-theme.js'

const { parse, create } = ClassName(theme)

const definition:Definition = parse('md:w-48');
// { responsiveModifier: 'md', property: 'width', prefix: 'w', value: 48 }

const className:string = create({ responsiveModifier: 'md', pseudoModifier: 'hover', property: 'backgroundColor', value: 'red-500' })
// 'md:hover:bg-48'

Rough checklist

This library will replace the tightly coupled utils - https://github.com/ui-devtools/ui-devtools/blob/main/packages/devtools/src/utils.js

About

Utilities to parse and create tailwindcss classes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages