The new Svelte (sv) CLI, adding Tailwind is simple now
Aight! With Svelte Summit Fall 2024 done with we got a load of cool new announcements, Svelte 5 being the big one along with the new site and docs! Beautiful!
One of the other big announcements was the new Svelte CLI sv which combines svelte-add with the create svelte command.
So, now rather than searching around for How to Set Up Svelte with Tailwind CSS itβs a couple of commands!
It can be installed as a global dependency or just run with npx.
To scaffold out a new project, I can use the sv CLI and give it a
name:
npx sv@latest create my-awesome-project Then I can add all the things! Check out the options!
npx sv@latest create my-awesome-project
β Welcome to the Svelte CLI! (v0.5.7)
β
β Which template would you like?
β SvelteKit minimal
β
β Add type checking with Typescript?
β Yes, using Typescript syntax
β
β Project created
β
β What would you like to add to your project?
β β» prettier (https://prettier.io)
β β» eslint
β β» vitest
β β» playwright
β β» tailwindcss
β β» drizzle
β β» lucia
β β» mdsvex
β β» paraglide
β β» storybook
β So I can go select ALL them things!
But Iβll just go with the defaults I always pick so that I can go over the other command:
npx sv@latest create my-awesome-project
β Welcome to the Svelte CLI! (v0.5.7)
β
β Which template would you like?
β SvelteKit minimal
β
β Add type checking with Typescript?
β Yes, using Typescript syntax
β
β Project created
β
β What would you like to add to your project?
β βΌ prettier
β βΌ eslint
β βΌ vitest
β βΌ playwright (https://playwright.dev)
β β» tailwindcss
β β» drizzle
β β» lucia
β β» mdsvex
β β» paraglide
β β» storybook
β Thatβll create my project, and the thing is, most of the use cases here will be people that already have a project and want to add Tailwind.
Now Iβve already got the project created, so I can just add Tailwind
with the add command:
npx sv@latest add tailwind
β Welcome to the Svelte CLI! (v0.5.7)
β
β Which plugins would you like to add?
β β» typography (@tailwindcss/typography)
β β» forms
β β» container-queries
β β» aspect-ratio
β Notice that I used the tailwind keyword in the command, this will
prompt for additional plugins to configure with it!
Alternatively, I can just run npx sv@latest add and then select
Tailwind from the list along with anything else Iβd like to configure!
Super neat!
Itβs early days for the new CLI and I have found an issue configuring MDSveX but itβs only going to get better from here with the prospect of community additions on the roadmap!
There's a reactions leaderboard you can check out too.
Sign up for the newsletter
Want to keep up to date with what I'm working on?
Join other developers and sign up for the newsletter.
I care about the protection of your data. Read the Privacy Policy for more info.