Generates TypeScript definitions from your tailwind.css file,
which allows you to use all of your project's Tailwind CSS classes and variants with full type-safety.
By default, create-tailwind-type writes two files:
tailwind.tstailwind_literal.ts
tailwind.ts exports Tailwind and TailwindNestGroups. Use these with
CreateTailwindest for typed style objects and nested variant keys.
tailwind_literal.ts exports TailwindLiteral. Use this with createTools
for typed class string arguments such as tw.join(...), tw.def(...), and
tw.style(...).class(...).
TailwindLiteral is generated as a precomputed static union so your app does
not need to evaluate Tailwind[keyof Tailwind] during type-checking.
Arbitrary strings are still controlled by useArbitrary: true in
CreateTailwindest and createTools.
Arbitrary and dynamic variant object keys, such as [&_p],
data-[size=large], aria-invalid, or group-aria-invalid, are controlled
by useArbitraryNestGroups: true in CreateTailwindest.
Generated arbitrary value template types are disabled by default for TypeScript
performance. Slash modifier variant template types are also disabled by
default. Enable these generated templates only when you specifically need
patterns such as bg-[${string}] or ring-${string}/${number}.
import { createTools, type CreateTailwindest } from "tailwindest"import type { Tailwind, TailwindNestGroups } from "./tailwind"import type { TailwindLiteral } from "./tailwind_literal"export type Tailwindest = CreateTailwindest<{ tailwind: Tailwind tailwindNestGroups: TailwindNestGroups useArbitrary: true useArbitraryNestGroups: true}>export const tw = createTools<{ tailwindest: Tailwindest tailwindLiteral: TailwindLiteral useArbitrary: true useTypedClassLiteral: true}>()
If you change the main output filename, the literal filename follows it. For
example, -f src/types/tailwind.d.ts also creates
src/types/tailwind_literal.d.ts.
Specifies the base directory for @tailwindcss/node package. If omitted, the tool automatically resolves to the installed @tailwindcss package directory.
None (auto-resolved)
-f
--filename <filename>
Sets the output filename for the generated Tailwind/TailwindNestGroups types. The TailwindLiteral file is emitted next to it with _literal suffix.
tailwind.ts
-d
--docs
Enables documentation comments in the generated types. Use the inverse flag to disable them.
true
-D
--no-docs
Disables documentation comments in the generated types.
N/A
-a
--arbitrary-value
Enables generated arbitrary value template types such as bg-[${string}]. This can slow TypeScript on large projects.
false
-A
--no-arbitrary-value
Explicitly disables arbitrary value template type generation.
N/A
N/A
--enable-variants
Enables generated slash modifier variant template types such as ring-${string}/${number}. This can slow TypeScript on large projects.
false
-N
--disable-variants
Explicitly disables slash modifier variant template type generation. This is already the default behavior.
N/A
-s
--soft-variants
Uses soft slash modifier templates when --enable-variants is set.
true
-S
--no-soft-variants
Uses exact slash modifier templates when --enable-variants is set.
N/A
-k
--string-kind-variants-only
Limits the generated types to only string kind variants.
false
-o
--optional-property
Generates optional properties in the output types, which can be useful for partial configurations.
false
N/A
--version
Displays the current CLI version.
N/A
N/A
--help
Displays help and usage information for the CLI tool.
Determines the output filename for the generated Tailwind and TailwindNestGroups TypeScript types. A sibling TailwindLiteral file is generated automatically.
Controls slash modifier variant template shape when --enable-variants is set.
Soft mode generates broader templates such as
ring-${string}/${number}. Exact mode generates templates from known class
groups instead.
Default: Soft mode is enabled (true), but slash modifier variant
generation is disabled unless --enable-variants is set.