Skip to main content

Overview

Svelte Atoms Core is headless by default, providing no opinionated styling. This gives you complete freedom to style components using your preferred approach: TailwindCSS, CSS modules, custom CSS, or any styling solution.
All components accept a class prop that supports strings, arrays, and objects for maximum flexibility.

TailwindCSS Integration

Svelte Atoms has first-class TailwindCSS support with powerful class merging and preset systems.

Basic Usage

Class Arrays

Pass arrays of classes for conditional styling:

Dynamic Classes with cn Utility

Use the built-in cn utility for conditional classes:

Preset System

The preset system enables consistent styling across your application with reusable configurations.

Creating a Preset

Using Presets

The $preset Placeholder

Control where preset classes are inserted using the $preset placeholder:
The $preset placeholder gives you precise control over class precedence and allows you to override preset classes with your own.

Variant System

Define variants directly on components:
Use the component:

CSS Modules

Use CSS modules for scoped styling:

Custom CSS

Use traditional CSS with custom classes:

Styled Components Pattern

Create pre-styled components:
Use it:

Theming

CSS Variables

Define themes with CSS variables:

TailwindCSS Dark Mode

Real-World Example: Button System

Create a comprehensive button system:
Use the button system:

Styling Best Practices

Define a spacing scale and stick to it. TailwindCSS provides this by default, or define your own:
Create styled wrapper components instead of repeating classes:
Avoid inline styles unless absolutely necessary. Use classes for better performance and maintainability.

Next Steps

Accessibility

Learn about built-in accessibility features

Animations

Add animations with lifecycle hooks

Composition

Master component composition patterns

Components

Browse all available components