Install the theui-svelte component library in your project or start a new project with the boilerplate template. Install it to build fast and deliver faster.
Installation
Requirements: Svelte 5.57.1 or newer, Tailwind CSS v4 and Node.js 22.12 or newer.
Follow one of the two methods to install the component library:
- Github boilerplate.
- Manual installation.
The form styles come with the package, so there is no Tailwind plugin to add by hand. The typography plugin is not included: install @tailwindcss/typography yourself if your own pages use its prose classes.
Use Github Boilerplate
To install the starter template clone this Github repo from your terminal using the following commands, replacing my-app with your desired project name.
# Clone the project
git clone https://github.com/mbparvezme/theui-svelte-starter.git my-app
# Navigate to the project directory
cd my-app
# Install node modules
npm install
# Run the application
npm run devManual Installation
Easily add theui-svelte to your project via a GitHub boilerplate or manual installation. For manual setup:
- Install Sveltekit with TailwindCSS and theui-svelte
- Configure Tailwind CSS by updating the
./src/app.cssfile.
2.1 Install
# Create a SvelteKit project
# When prompted "What would you like to add to your project?", select tailwindcss
npx sv create my-app
cd my-app
# Add Tailwind CSS - if you didn't select tailwindcss during the project creation, run:
# npx sv add tailwindcss
# Install theui-svelte
npm install theui-svelte2.2 Configuration
To integrate theui-svelte with your project, add the following lines to your ./src/app.css file:
@import 'tailwindcss';
+ @import 'theui-svelte/style';
+ @source "../node_modules/theui-svelte";That's it! You're ready to start building your awesome project. Now, run your application with:
# Run SvelteKit project
npm run devYour First Component
Components are named exports of theui-svelte, so you import the ones you use and nothing else. Drop this into a page to see that everything is wired up: the button raises a notification, which means the components, the styles and the store are all working.
<script>
import { Button, Notification, notify } from "theui-svelte"
</script>
<Notification position="top-end" />
<Button onclick={() => notify("It works", "success")}>Say hello</Button>Two more entry points come with the package: theui-svelte/type for the TypeScript types, and theui-svelte/function for helpers such as notify and sanitize.
Dark Mode
Dark mode is driven by a dark class on the <html> element. The stylesheet you imported brings the variant with it, so there is nothing to add to your Tailwind setup, and every component already carries its dark styles.
Put the DarkMode component somewhere in your layout and it does the rest: it follows the operating system until someone chooses for themselves, then remembers that choice.
Upgrading From Version 2
Version 3 is a break with version 2. These are the changes most likely to touch your code:
- Svelte 5.57.1 or newer and Node.js 22.12 or newer are required.
- The brand colors were renamed:
brand-primary-50...brand-primary-950are nowbrand-50...brand-950, andtext-on-brand-primaryis nowtext-on-brand. Rename them in your markup, and rename--color-brand-primary-*and--text-color-on-brand-primaryif you overrode them. - The second brand color is gone.
brand-secondary-*andtext-on-brand-secondaryno longer exist; use any Tailwind color, or one of your own, in their place. - The raw surface values are prefixed now:
--light1...--dark3are--theui-light1...--theui-dark3. This only matters if you overrode them;bg-primary,bg-secondaryandbg-tertiaryare unchanged. - String props such as
helperText, atitleor alabelrender as plain text now. Pass a snippet, or write the content inside the component, where you used to pass markup. TabandTabPaneleach need avalue, and a tab opens the panel that carries the same one.Toggleusescheckedfor a checkbox andgroupfor a radio;valueis now only the value of the input.- The
reverseattribute ofCheckbox,RadioandToggleis nowlabelPosition. Button,QabItemandNavBrandno longer invent anaria-label, so give icon-only controls anariaLabelof your own.- The
positionsetting ofnotify()moved to thepositionprop of theNotificationcomponent. style.cssno longer loads@tailwindcss/typography.
The changelog in the GitHub repository lists every change, including the rewritten Slider and the new components.