Skip to content

Setting up your editor for class-recipe

If you use Tailwind CSS, your editor can complete, preview, and lint the classes inside a recipe, as it does in a className attribute, and Prettier can sort them. Both need the names of the functions whose arguments hold classes.

Tailwind CSS IntelliSense reads the classFunctions setting, a list of function names. Every string in a call to one of them, including the strings nested in a recipe’s config, gets completions, hover previews, and linting.

Install the Tailwind CSS IntelliSense extension, and add to .vscode/settings.json:

{
"tailwindCSS.classFunctions": ["cva", "sva", "cx"]
}

prettier-plugin-tailwindcss sorts the classes in the calls of the functions listed in its tailwindFunctions option, including the strings nested in a recipe’s config:

.prettierrc
{
"plugins": ["prettier-plugin-tailwindcss"],
"tailwindStylesheet": "./src/app.css",
"tailwindFunctions": ["cva", "sva", "cx"]
}

tailwindStylesheet is the CSS file that imports Tailwind CSS v4. With Tailwind CSS v3, set tailwindConfig to your tailwind.config.js instead.

List every name you call the functions by:

  • createRecipe and createSlotRecipe, if you import the long names.
  • The names you give the functions of createRecipes, such as tv in export const { cva: tv } = createRecipes({ join: twMerge }).