This guide will walk you through setting up a modern CSS architecture using Tailwind CSS v4 and OpenProps to create a flexible, customizable design system with your own design tokens.
First, set up a new project with SvelteKit: You can allready choose tailwindcss from the install menu.
# Create a new SvelteKit project
npx sv create my-app
cd my-app
# Install dependencies
npm install
# Install OpenProps
npm install -D open-props
OpenProps provides a set of design tokens that work well with Tailwind 4 without being opinionated about your design choices. This gives you the flexibility to create unique designs while maintaining consistency.
Create visually harmonious designs with OpenProps' carefully curated design tokens that work well together out of the box.
Thanks to consistent naming conventions across all properties, you'll spend less time guessing and more time building.
Whether you want to use all the props, just the ones you need, or even import them as JavaScript objects, OpenProps adapts to your workflow.
Easily map the props from JavaScript or customize builds from the command line to fit your project's specific needs.
Edit src/app.css
file with the basic configuration:
@import 'tailwindcss';
@import 'open-props/style';
@theme {
/* We'll add our theme configurations here */
}
Tailwind v4 makes it easy to map your own font sizes using CSS custom properties:
@theme {
--font-size-*: initial;
--font-size-00: var(--font-size-00);
--font-size-0: var(--font-size-0);
--font-size-1: var(--font-size-1);
--font-size-2: var(--font-size-2);
--font-size-3: var(--font-size-3);
--font-size-4: var(--font-size-4);
--font-size-5: var(--font-size-5);
--font-size-6: var(--font-size-6);
--font-size-7: var(--font-size-7);
--font-size-8: var(--font-size-8);
}
Usage:
<h1 class="text-5">Hello World</h1>
Easily add beautiful gradients from OpenProps:
@theme {
--background-image-gradient-1: var(--gradient-1);
--background-image-gradient-2: var(--gradient-2);
--background-image-gradient-3: var(--gradient-3);
/* Add more gradients as needed */
}
Usage:
<div class="bg-gradient-3">
<!-- Your content -->
</div>
Create adaptive utilities that automatically adjust for light and dark modes:
:root {
--ink-1: var(--gray-9);
--ink-2: var(--gray-7);
--surface-1: var(--gray-2);
--surface-2: var(--gray-1);
--link: var(--indigo-6);
}
@media (prefers-color-scheme: dark) {
:root {
--ink-1: var(--gray-1);
--ink-2: var(--gray-5);
--surface-1: var(--gray-11);
--surface-2: var(--gray-10);
--link: var(--indigo-4);
}
}
@theme {
--color-ink-1: var(--ink-1);
--color-ink-2: var(--ink-2);
--color-surface-1: var(--surface-1);
--color-surface-2: var(--surface-2);
--color-link: var(--link);
}
Now you can use these adaptive utilities in your components:
<div class="bg-surface-2">
<header>
<h1 class="text-ink-1">Adaptive Heading</h1>
<p class="text-ink-2">This text automatically adapts to light/dark mode</p>
<a href="#" class="text-link">Adaptive Link</a>
</header>
</div>
This project comes with a fully configured development container that includes multiple JavaScript/TypeScript runtimes and package managers. The container is pre-configured with all necessary tools for a smooth development experience.
The development container includes the following runtimes and package managers:
This project includes npm-check-updates
to easily update your dependencies. To update all dependencies to their latest versions:
npm-check-updates
ncu -u
npm install
You can use any of the following package managers (all pre-installed):
# Using npm
npm install
# Using Yarn
yarn install
# Using pnpm
pnpm install
# Using Bun
bun install
# Using Deno
deno install
The project includes a comprehensive Makefile
with useful commands for development, building, testing, and maintaining your application:
make create # Create a new Svelte project
make setup # Install dependencies
make add pkg=package # Add a new package
make dev # Start development server
make build # Build for production
make preview # Preview production build
make check # Check for errors
make test # Run tests
make test-watch # Run tests in watch mode
make test-coverage # Generate test coverage
make lint # Run linter
make format # Format code
make typecheck # Check types
make migrate # Run available migrations
make migrate-svelte5 # Migrate to Svelte 5
make migrate-kit2 # Migrate to SvelteKit 2
make add-drizzle # Add Drizzle ORM
make add-eslint # Add ESLint
make add-lucia # Add Lucia authentication
make add-mdsvex # Add mdsvex (Markdown)
make add-playwright # Add Playwright tests
make add-prettier # Add Prettier
make add-storybook # Add Storybook
To start the development container, use VS Code's "Reopen in Container" command or run:
docker-compose up -d
Authors: Digi4Care
Maintainer: Chris Engelhard
License: MIT