Svelte
Install Manicat UI components as Svelte 5 components that read the same CSS tokens as the React library.
Svelte ports are *.svelte components written with runes ($props, $state, $derived, $bindable) and snippets.
Their styles are plain CSS that reads the variables of foundation.css, the same file the React and Vue versions use.
Requirements
- Svelte 5 (runes mode)
- TypeScript with
svelte-checkif you typecheck - Vite with
@sveltejs/vite-plugin-svelte, or SvelteKit
Install
npx shadcn@latest add @manicat/button-svelteThe CLI also adds manicat-foundation. Import the tokens once at the root of your app:
import "$lib/components/manicat/foundation.css";Use it
<script lang="ts">
import Button from "$lib/components/manicat/button/button.svelte";
let saving = $state(false);
async function save() {
saving = true;
await new Promise((done) => setTimeout(done, 1200));
saving = false;
}
</script>
<Button loading={saving} onclick={save}>Save changes</Button>
<Button variant="secondary">Cancel</Button>Content goes in the children snippet. Components with an icon take an icon snippet, and controlled inputs use
bind::
<Switch bind:checked={push} label="Push notifications" />Customising parts with classNames
<Button classNames={{ label: "font-semibold" }}>Delete project</Button>Rest props fall through to the root element, so class and the usual attributes work as expected.
See it running
pnpm --filter @manicat/preview-svelte dev # http://localhost:3001