Installation
Install Tailwind CSS with SvelteKit
Setting up Tailwind CSS in a SvelteKit project.
The quickest way to start using Tailwind CSS in your SvelteKit project is to use the SvelteKit Introduction Guide and Tailwind CSS with svelte-add to automatically setup your project. That's it, it is that easy to get Tailwind CSS configured in a SvelteKit project!

Create your project
Start by creating a new SvelteKit project if you don't have one set up already. The most common approach is outlined in the Getting Started with SvelteKit introduction.
Terminalnpm init svelte@next my-appcd my-app
Install Tailwind CSS
Use the community project Svelte Add to generate
tailwindcss.config.cjs
,postcss.config.cjs
, and stub files for your css and layout. Then installtailwindcss
and it's peer dependencies via npm.Terminalnpx svelte-add@latest tailwindcssnpm install
Configure your template paths
Add the paths to all of your template files in the generated
tailwind.config.cjs
file.tailwind.config.cjsconst config = { content: ['./src/**/*.{html,js,svelte,ts}'], theme: { extend: {} }, plugins: []}; module.exports = config;
Add the Tailwind directives to your CSS
Add the
@tailwind
directives for each of Tailwind's layers to your./src/app.css
file if not.app.css@tailwind base; @tailwind components; @tailwind utilities;
Start your build process
Run your build process with
npm run dev
.Terminalnpm run dev
Start using Tailwind in your project
Start using Tailwind’s utility classes to style your content.
index.svelte<h1 class="text-3xl font-bold underline"> Hello world!</h1>