Skip to content

therealzaybee/tailwind-class-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

It validates whether a string (single / multiple separated by spaces) is a valid tailwind css class or not.

Installation

npm install @jyotirmay/tailwind-class-validator

Usage

// index.ts
import { isValidTailwindClass } from'@jyotirmay/tailwind-class-validator';

(async ()=>{
    let res = await isValidTailwindClass("text-red-500", { /** Options */ })
    console.log(res);
    /*
        Output: 
        {
            success: true,
            css: '.cls {\n' +
            '    --tw-text-opacity: 1;\n' +
            '    color: rgb(239 68 68 / var(--tw-text-opacity))\n' +
            '}'
        }
    */

    // With options

    let opts = { 
        plugins:{ 
            typography: true // For tailwind-typography support
        }, 
        outputClass: "out" // to modify classname in `res.css`. The default is "cls" 
    }

    res = await isValidTailwindClass("text-red-500", opts)
    console.log(res);
    /*
        Output: 
        {
            success: true,
            css: '.out {\n' +
            '    --tw-text-opacity: 1;\n' +
            '    color: rgb(239 68 68 / var(--tw-text-opacity))\n' +
            '}'
        }
    */
})()

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published