Features
Themes
Customizing your application's look and feel
SvelteLaunch now uses ShadCN for theming, which provides a powerful and flexible way to style your application. The theming system is built on top of Tailwind CSS, giving you extensive customization options. There are several themes available at the link below.
Resources:
Customizing Themes
With ShadCN, you have full control over your application's theme. You can customize colors, typography, spacing, and more to match your brand or design preferences.
Installing and Configuring Themes
To set up your theme, including both light and dark modes, you need to modify the /src/routes/app.css
file. This file defines the color variables for both light and dark themes.
- Open
/src/routes/app.css
- Replace the existing content with the following:
This configuration defines color variables for both light and dark themes. The :root
selector sets the default (light) theme, while the .dark
class defines the dark theme colors.
How it works with Tailwind CSS
Tailwind CSS makes it easy to handle both light and dark modes using these color variables. Instead of specifying separate colors for light and dark modes (e.g., text-black dark:text-white
), you can use the semantic color classes like bg-background
or text-foreground
.
For example:
This approach works because:
- The
bg-background
andtext-foreground
classes use the CSS variables defined inapp.css
. - When the
.dark
class is added to a parent element (usually the<html>
or<body>
tag), it overrides the default color variables with the dark theme values. - Tailwind CSS automatically applies the correct colors based on whether the dark mode is active or not.
Customizing a ShadCN Theme
shadcn-svelte uses Tailwind CSS for styling. To customize the overall theme:
Open your
tailwind.config.js
file.Modify the
theme
section to adjust colors, fonts, and other design tokens:The changes will be reflected across all shadcn-svelte components that use these theme values.
Toggling Dark Mode
To toggle dark mode, you can add or remove the dark
class from a parent element, typically the <html>
tag:
This approach provides a clean and maintainable way to handle theming in your application, as you only need to define your colors once and use semantic class names throughout your HTML.
Remember to use the appropriate semantic color classes (like bg-background
, text-foreground
, bg-primary
, etc.) in your components to ensure they respond correctly to theme changes.
Remember to test your customizations thoroughly to ensure they work well across different screen sizes and in both light and dark modes. By leveraging ShadCN and Tailwind CSS, you have the flexibility to create a unique and consistent design system for your Svelte application.