Extend Tailwind configuration using Nuxt hooks
main@nuxtjs/tailwindcss module is extendable. You can use Nuxt hooks to interact with the Tailwind configuration process, allowing other Nuxt modules to inject or modify styles and configurations.repository·main·Indexed 23 days ago
https://github.com/nuxt-modules/tailwindcssA Nuxt module providing seamless integration for Tailwind CSS, allowing the use of utility classes in Nuxt applications with zero configuration. Includes support for extending Tailwind configuration via Nuxt hooks, such as tailwindcss:sources:extend, and provides a `tw` autocomplete utility to enable Tailwind CSS IntelliSense for class strings and template literals.
@nuxtjs/tailwindcss module is extendable. You can use Nuxt hooks to interact with the Tailwind configuration process, allowing other Nuxt modules to inject or modify styles and configurations.You can manually install the module using your preferred package manager and then register it in your Nuxt configuration file.
# Using pnpm
pnpm add --save-dev @nuxtjs/tailwindcss
# Using yarn
yarn add --dev @nuxtjs/tailwindcss
# Using npm
npm install --save-dev @nuxtjs/tailwindcssThe fastest way to add Tailwind CSS support to your Nuxt project is by using the Nuxt CLI module command. This automatically handles the installation and registration of the module.
npx nuxi@latest module add tailwindcssYou can extend the list of files that Tailwind CSS scans for classes by using the tailwindcss:sources:extend hook. This hook provides an array of source objects that you can modify. Each object in the array contains a type and a source string.
Use this hook within your Nuxt configuration or a Nuxt plugin to add custom directories or files to the Tailwind scanning process.
The module provides an autocompleteUtil which is automatically imported and aliased as tw. You can use this utility in your project to assist with Tailwind CSS related logic or autocompletion tasks.
Access it directly in your components or composables as tw.
autocompleteUtil function is a utility used to wrap Tailwind class strings or template literals. This allows the Tailwind CSS IntelliSense engine (or other autocomplete tools) to recognize these strings as Tailwind classes, enabling autocomplete suggestions within your code.