Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Brings types to TailwindCSS via TypeScript.
Typed Tailwind is a code-generation tool that turns a Tailwind CSS config into a TypeScript class of chainable, type-checked utility methods for building className strings.
Typed Tailwind is a developer tool that brings static typing to Tailwind CSS. It takes your Tailwind configuration file as input and generates a single TypeScript file containing a class whose methods correspond to every utility class in your config. This generated file can be imported into any TypeScript project, and its methods enforce valid utility names at compile time — catching typos and undefined colors before your code runs. The project is MIT-licensed, hosted on GitHub as dvkndn/typed-tailwind.thien.do, and was created by Thien Do (dvkndn). The project is now archived, with the author recommending stitchesjs/stitches for those looking for a maintained alternative.
Tw().textBlue().fontBold().$() to combine multiple utilities; the $() method returns the final className string.typed-tailwind-loader resolves all Tw()...$() calls at compile time, eliminating runtime overhead and producing static class strings that work with PurgeCSS.Typed Tailwind targets TypeScript developers who use Tailwind CSS and want to extend their type safety from logic into styling. It is particularly useful for:
The workflow is a four-step process. First, go to typed-tailwind.thien.do (or typed-tailwind.com if .tw is inaccessible) and paste your Tailwind configuration into the first panel. Second, save the TypeScript file shown in the second panel into your codebase. Third, import the Tw function from that file. Finally, chain utility methods and end with $() to produce the className string, e.g. Tw().textBlue().fontBold().$(). For compile-time transformation, install the webpack loader and configure it in your build.
text-blud class at runtime, TypeScript reports the error during development.Place it somewhere you can import it with absolute paths, e.g. src/tw/index.ts in a CRA project with baseUrl set to src. Then import the Tw function as import { Tw } from "tw".
Yes. You can compile the generated file to JavaScript with tsc --declaration style.ts. You still get code completion via the declaration file, but you lose compile-time type checking of utility names.
Yes, if you use the webpack loader. The loader resolves Tw()...$() calls during the build, producing plain class strings that PurgeCSS can scan. Without the loader, runtime generation prevents PurgeCSS from seeing the class names.
It's not officially supported, but plugins defined as inline anonymous functions may work. You can always extend the generated class manually with custom methods.
At runtime, styling is applied by looking up and concatenating class names on every render, which adds overhead. Using the webpack loader moves this work to compile time and eliminates that issue. If you can't modify the build config, hoist the Tw() call outside the component so it runs once at startup.