Having trouble memorizing all the utility classes in Tailwind? Remembered the CSS code, but did not remember which is the corresponding Tailwind CSS utility class? Search for it here!
This little web application parses the Tailwind CSS file right from unpkg.com
using css-tree, and generates a searchable index that lets you search for a utility class’s name, if you know the generated CSS code you want. The web app is built with Vue.js, fast fuzzy-searching is provided by fuzzysort and the result list is lazily rendered with help of vue-virtual-scroller.
I made this application because I am often confused by Tailwind CSS’ naming of classes.
font-
? e.g. font-bold
text-
? e.g. text-lg
even though it’s font-size
italic
index.html
file in your browser. Edit, save and refresh. Append ?dev=1
to URL to load full Tailwind CSS file.const fs = require('fs')
const tailwindCssClassSearch = require('@dtinth/tailwind-css-class-search')
// Read CSS file
const css = fs.readFileSync(require.resolve('tailwindcss/dist/tailwind.css'))
// Generate a search index
const searchIndex = await tailwindCssClassSearch(css)
// Inspect all entries
searchIndex.entries // => Array(12526)
// Search
searchIndex.search('font-size') // Array(50)
Since the full generated tailwind is 1mb large, we use purgecss to remove unused selectors and reduce the CSS file size to 20kb.
yarn build
See the contrib/vscode
folder for more info on experimental VS Code integration.