Skip to content
Sveltier
Mode
API

UIProvider

The root of a Sveltier app: theme, defaults, breakpoints and locale in one component.

Props

NameTypeDefaultDescription
themesRecord<string, ThemeDefinition>–Required. The registered themes, for example monolith or { ...monolith, ...maison }. An app ships only the packs it registers.
theme'system' | string'system'The theme to show, or "system" to follow prefers-color-scheme. Bindable.
light / darkstringfirst light / dark themeThe pair used by "system" and toggle().
storageKeystring | false'sv-theme'Where the theme choice is remembered and restored before first paint. false turns it off.
noncestring–CSP nonce for the generated <style> and <script>.
defaultsDefaultsConfig–Default props for every component below: global, and per component.
displayDisplayOptions–Breakpoint thresholds, the mobile breakpoint and the width assumed on the server (ssrWidth). Read once.
localeLocaleOptions–Locale, currency, time zone and messages. Changes apply at once.
childrenSnippet–The app.

Example

+layout.svelte
<!-- src/routes/+layout.svelte -->
<script>
  import { UIProvider } from 'sveltier';
  import { monolith } from 'sveltier/themes/monolith';
  let { children } = $props();
</script>

<!-- Monolith, light or dark following the OS -->
<UIProvider themes={monolith}>
  {@render children()}
</UIProvider>

What it renders

It gives everything below it the display and locale settings, then renders a root ThemeProvider around a DefaultsProvider. Neither renders an element. Use one UIProvider at the root; inside it, a nested ThemeProvider or DefaultsProvider changes the theme or defaults of a section.

See Quick start for the setup, and ThemeProvider for theme scopes.