
Product
Introducing Webhook Events for Pull Request Scans
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
@toddledev/tailwind-parser
Advanced tools
A lightweight library for parsing Tailwind CSS classes and converting HTML with Tailwind classes to a custom node tree structure.
A lightweight library for parsing Tailwind CSS classes and converting HTML with Tailwind classes to a custom node tree structure.
npm install @toddledev/tailwind-parser
or
yarn add @toddledev/tailwind-parser
import { parseClassString } from '@toddledev/tailwind-parser';
const classString = 'bg-blue-500 hover:bg-blue-600 p-4';
const { style, variants } = parseClassString(classString);
console.log(style); // Object containing parsed styles
console.log(variants); // Array of parsed variants
import { tailwindToToddle } from '@toddledev/tailwind-parser';
const html = '<div class="bg-red-500 p-4"><span class="text-white">Hello, World!</span></div>';
const nodeTree = tailwindToToddle(html);
console.log(nodeTree);
parseClassString(classString: string): { style: Record<string, string>, variants: Variant[] }
Parses a string of Tailwind CSS classes and returns an object containing the parsed styles and variants.
tailwindToToddle(html: string): NodeTree
Converts an HTML string with Tailwind classes to a custom node tree structure.
The library exports the following types:
Variant
NodeTree
ElementNode
TextNode
Contributions are welcome! Please feel free to submit a Pull Request.
If you find any bugs or have feature requests, please create an issue on the GitHub repository.
FAQs
A lightweight library for parsing Tailwind CSS classes and converting HTML with Tailwind classes to a custom node tree structure.
We found that @toddledev/tailwind-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.
Product
A single platform for static analysis, secrets detection, container scanning, and CVE checks—built on trusted open source tools, ready to run out of the box.