Skip to content

Installation

Add FancyUI to a SvelteKit project in three steps: install the package, import the stylesheet, render a component.

Svelte 5 Tailwind CSS 4 Node.js 20.19+ TypeScript

Prerequisites

FancyUI targets current toolchains. Check these three before installing.

Svelte Svelte 5

Components are written with runes, so Svelte 5 is required. Svelte 4 projects will not compile them.

Tailwind CSS v4

Styling relies on Tailwind v4 utilities and CSS custom properties.

Node.js 20.19+

Required by the current build tooling FancyUI is tested against.

SvelteKit is optional: FancyUI works in any Svelte 5 project built with Vite.

Install

Pick your package manager, wire up the stylesheet, then render your first component.

  1. Install the package

    One package for every component. Switch tabs to copy the command for your package manager.

    pnpm add fancy-ui-svelte
    import { RainbowButton } from 'fancy-ui-svelte';
  2. Import the stylesheet

    Add the FancyUI stylesheet right after your Tailwind import.

    css
    @import "tailwindcss";
    @import "fancy-ui-svelte/tailwind.css";

    In your global stylesheet, usually src/app.css.

  3. Render a component

    Import from the package root and drop it into your markup.

    svelte
    <script lang="ts">
    	import { RainbowButton } from 'fancy-ui-svelte';
    </script>
    
    <RainbowButton>Click me</RainbowButton>

Tailwind CSS setup

FancyUI is built on Tailwind CSS v4, which is configured in CSS instead of a JavaScript config file. If Tailwind already works in your project, there is nothing else to configure.

Import order matters: Tailwind first, FancyUI second. Place the FancyUI import before your own @custom-variant dark, otherwise FancyUI's replaces yours.

The entry provides default colour tokens (background, primary, border and the rest) and a dark variant. Your own :root and .dark blocks override them: redefine the CSS variables and your values win.

Usage

Every component is a named export of the package root, so there are no per-component import paths to remember.

svelte
<script lang="ts">
	import { BorderBeam, RainbowButton } from 'fancy-ui-svelte';
</script>

<div class="relative overflow-hidden rounded-xl border p-8">
	<RainbowButton>Click me</RainbowButton>
	<BorderBeam colorFrom="#9E7AFF" colorTo="#FE8BBB" />
</div>

Each component's page lists its props, live examples and accessibility notes.

TypeScript

Prop types are exported next to each component, so you can type wrappers and shared presets.

ts
import { type BorderBeamProps } from 'fancy-ui-svelte';

const beam: BorderBeamProps = { colorFrom: "#9E7AFF", colorTo: "#FE8BBB" };

Types ship inside the package. There is no separate types package to install.

Peer dependencies

FancyUI expects these to already exist in your project:

PackageVersion
svelte^5.20.0
tailwindcss^4.0.0
@sveltejs/kit optional>=2.0.0

A few components need extra runtime libraries. These ship with the package, so there is nothing more to install:

@chenglou/pretextcanvas-confetticlsxgsaptailwind-mergethree

They are only pulled in by the components that use them.

Astro

FancyUI runs in Astro through the official Svelte integration, with no extra package. Add the integration and Tailwind, install the package, then import the stylesheet from step 2 in your layout.

bash
npx astro add svelte
npx astro add tailwind
npm install fancy-ui-svelte
js
import { defineConfig } from "astro/config";
import svelte from "@astrojs/svelte";
import tailwindcss from "@tailwindcss/vite";

export default defineConfig({
	integrations: [svelte()],
	vite: { plugins: [tailwindcss()] },
});

A component used without a client:* directive renders to HTML and CSS and ships no JavaScript. BorderBeam, Marquee, Meteors, and buttons without a handler work this way.

astro
---
import { BorderBeam, Meteors } from "fancy-ui-svelte";
---

<div class="relative overflow-hidden rounded-xl border p-8">
	<Meteors />
	<BorderBeam />
</div>

To hydrate a component, import it in a local .svelte file and put the directive on that file. Plain props cross from .astro as data and slots, default or named, arrive as static HTML, but functions do not serialize: handlers, callbacks and snippets that take arguments are written in the .svelte file.

svelte
<script lang="ts">
	import { RainbowButton } from "fancy-ui-svelte";

	let clicks = $state(0);
</script>

<RainbowButton onclick={() => clicks++}>Clicked {clicks} times</RainbowButton>
astro
---
import Counter from "../islands/Counter.svelte";
---

<Counter client:visible />

Do not put the directive on a component imported from fancy-ui-svelte in an .astro file: Astro's island loads the whole module it was imported from. For a page with one RainbowButton island, the local file ships about 88 KB of JavaScript (32 KB gzipped, Astro's Svelte runtime included); the package-root import ships about 1.66 MB (481 KB gzipped), three.js and GSAP included, and the build can then share that chunk with the other island pages of the site.

ClientRouter is supported: islands are destroyed on each navigation, and transition:persist keeps one alive across pages.

Tested with astro 7.4.2 and @astrojs/svelte 9.1.1, which need Node 22.23.4 or later.

Next steps