
Product
Introducing GitHub Actions Scanning Support
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.
@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): NodeTreeConverts an HTML string with Tailwind classes to a custom node tree structure.
The library exports the following types:
VariantNodeTreeElementNodeTextNodeContributions 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.
The npm package @toddledev/tailwind-parser receives a total of 249 weekly downloads. As such, @toddledev/tailwind-parser popularity was classified as not popular.
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
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.

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.