Repository navigation
How do you apply a new theme present in an existing project? #2784
|
I wanted to ask how do you apply a new present in an svelte shadcn project? Like in the shadcn react there's a apply cli command to do that. Is the only way to do it is with init command? I am just asking, i mean the init works too but i just wanted to know. |
Replies: 2 comments 1 reply
|
You don't need npx shadcn-svelte@latest apply <preset-code>To get a preset code, build your theme at https://shadcn-svelte.com/create. The button there copies npx shadcn-svelte@latest apply <code>
npx shadcn-svelte@latest apply --preset <code>What it does in an existing project:
If you only want the colors or the font and don't want to touch components or dependencies, use npx shadcn-svelte@latest apply <code> --only theme
npx shadcn-svelte@latest apply <code> --only fontNote that Docs: https://shadcn-svelte.com/docs/cli#apply |
You don't need
initanymore. The PR linked above (#2751) added anapplycommand, which shipped inshadcn-svelte@1.4.0, so any recent version has it (current is 1.7.0):To get a preset code, build your theme at https://shadcn-svelte.com/create. The button there copies
--preset <code>, so either of these works:What it does in an existing project:
components.jsonand errors out if there isn't one. It updates the style, base color, icon library and menu settings in that file to match the preset./init…