Skip to main content

Design Principle

All atoms in Svelte Atoms Core inherit from the base atom.svelte component, making them composable by default. This means you can freely mix and match atoms to create complex interactions without custom integration code.
Composition over inheritance: Rather than extending base classes, you compose multiple atoms together to create the functionality you need.

Basic Composition

Atoms as Building Blocks

Start by combining simple atoms to create more complex components:

Composition Patterns

1. Dropdown Triggers

Any atom can serve as a dropdown trigger:

2. Modal Triggers

Compose dialogs with any clickable atom:

3. Form Field Composition

Combine atoms to create rich form controls:

Advanced Composition

Nested Atoms

Create deeply nested compositions:

Dynamic Composition

Compose atoms dynamically based on state:

Composition with Snippets

Use Svelte 5 snippets to create reusable composition patterns:

Base Component Composition

Use the base prop to compose components at a deeper level:
Combining multiple atoms to create a functional search component:
This example composes Combobox, Input, Avatar, and Badge atoms into a rich search interface without any custom integration code.

Composition Best Practices

1. Keep Compositions Focused

2. Use Semantic Structure

3. Extract Reusable Compositions

Then use it:
Don’t over-abstract. Create reusable compositions only when you use the same pattern 3+ times.

Benefits of Composition

Flexibility

Mix and match atoms freely to create any UI pattern you need

Maintainability

Changes to base atoms automatically propagate to all compositions

Testability

Test individual atoms and compositions independently

Next Steps

Styling

Learn how to style composed components with TailwindCSS

Accessibility

Ensure your compositions are accessible to all users

Animations

Add animations to your composed components

Components

Browse all available atoms and their APIs