Styling and theming

Customize Fractalsvelte through its tokens, SASS entry point, and generated utility classes.

Start with tokens

Fractalsvelte reads its shared colors from CSS custom properties. Override them under :root to theme the whole application, or under a parent class to theme one region.

SASS
:root
	--color00: #FFFFFF
	--color10: #F5F5F5
	--color100: #111111
	--accent10: #388E3C
	--accent20: #1B5E20
	--text-primary: var(--color100)
	--text-secondary: var(--color60)
	--border-primary: var(--color30)

The most frequently used tokens are:

TokenPurpose
--color00 to --color100Neutral surface and text scale
--accent10, --accent20, --accent30Primary interactive colour scale
--danger10, --danger20Destructive or error states
--text-primary, --text-secondary, --text-tertiaryText hierarchy
--border-primary, --border-secondary, --border-tertiaryBorders and dividers
--font-defaultShared font family

Scope a theme

Tokens inherit, so a class can provide a dark or branded surface without changing the rest of the application.

SASS
.theme-dark
	--color00: #111111
	--color10: #1D1D1D
	--color100: #F5F5F5
	--text-primary: var(--color100)
	--text-secondary: var(--color50)
	--border-primary: var(--color70)
Svelte
<section class="theme-dark pad32">
	<!-- Components inside inherit these tokens. -->
</section>

Use the provided primitives

The global SASS entry point provides structural primitives such as box, row, and grid, alongside button and typography classes. Keep layout concerns in markup and use component-scoped SASS for a component’s unique visual behavior.

Svelte
<div class="box gap16">
	<div class="row xbetween ycenter gap8">
		<h2>Profile</h2>
		<button class="btn btn-secondary">Edit</button>
	</div>
</div>

Generated spacing and sizing utilities

With fractals-styler configured, numeric utilities are generated from your source at build time:

ClassEffect
gap16gap: 16px
pad32padding: 32px
marginbot16margin-bottom: 16px
width128width: 128px

Breakpoint suffixes such as pad16-sm and text-lg-xs are available for the Styler’s own utilities. Use the SASS breakpoint mixins for custom selectors.

Keep component overrides local

Components use scoped <style lang="sass"> blocks. Prefer an application-level wrapper class and token overrides before targeting a component’s internal markup. This keeps upgrades and composition predictable.