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:
1npx sv@latest create my-awesome-projectThen I can add all the things! Check out the options!
1npx sv@latest create my-awesome-project
2β Welcome to the Svelte CLI! (v0.5.7)
3β
4β Which template would you like?
5β SvelteKit minimal
6β
7β Add type checking with Typescript?
8β Yes, using Typescript syntax
9β
10β Project created
11β
12β What would you like to add to your project?
13β β» prettier (https://prettier.io)
14β β» eslint
15β β» vitest
16β β» playwright
17β β» tailwindcss
18β β» drizzle
19β β» lucia
20β β» mdsvex
21β β» paraglide
22β β» storybook
23β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:
1npx sv@latest create my-awesome-project
2β Welcome to the Svelte CLI! (v0.5.7)
3β
4β Which template would you like?
5β SvelteKit minimal
6β
7β Add type checking with Typescript?
8β Yes, using Typescript syntax
9β
10β Project created
11β
12β What would you like to add to your project?
13β βΌ prettier
14β βΌ eslint
15β βΌ vitest
16β βΌ playwright (https://playwright.dev)
17β β» tailwindcss
18β β» drizzle
19β β» lucia
20β β» mdsvex
21β β» paraglide
22β β» storybook
23β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:
1npx sv@latest add tailwind
2β Welcome to the Svelte CLI! (v0.5.7)
3β
4β Which plugins would you like to add?
5β β» typography (@tailwindcss/typography)
6β β» forms
7β β» container-queries
8β β» aspect-ratio
9β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.