PrimeBrickPrimeBrick
  • Docs
  • Contact
  • MIT License
  • Documentation
  • MCP Server
  • API Catalog
  • Services
  • Libraries
PrimeBrickPrimeBrick

© 2026 PrimeBrick. MIT License. v3.11.2

github
Backend
Frontend
    Developer Guide
      OverviewGetting startedUI stackApp shell & sidebarAuthentication & sessionsSystem settingsUI componentsUI patternsIcon ConventionsInput AnatomyField Hints & TooltipsButton Style StandardsEntity metadatai18n — Translations on the FrontendThe AI Tool Loop (caller-driven)Error HandlingComposables (use* hooks)
      Components
        Entity list tableComboSelectDynamicIconColorSelectorColorPickerAvatarPreviewEventCardCommandPaletteAppShellAppSidebarAppTopbarAppPageLayoutAppPageScaffoldAppPageBreadcrumbAppServerBannerBrowserClientInfoLangSelectThemeToggleSidebarAppLauncherSidebarHealthBadgeSidebarOrgSwitcherSidebarProfileMenuSidebarVersionBadgeButtonButton (async)FormPageLayoutFormLabelWithPriorityHelpPasswordChecklistChoiceboxDateWheelPickerEventToastLoadingBarMetadataLoadingJsonTableViewerNumberTickerStatCardToolbarDialogBorderedEntity Confirm DialogsSheet panelRFCErrorDialogLoginFormPasskeyButtonPasskeyEnrollmentAuthMethodsPromptDialogSessionExpiredDialogInputSliderSliderFieldSwitchFieldSelectableFieldsetBadgeValuesEditorTooltipFormPrimeFieldSmartRegexInput
      API Reference
Microservices
powered by Zudoku
Components

ThemeToggle

src/lib/components/ThemeToggle.svelte

Purpose

A ghost icon button that toggles between light and dark themes. On mount it reads the saved preference from localStorage under the pb.theme key; if none is saved, it falls back to the OS prefers-color-scheme media query. Toggling applies the dark class on document.documentElement and persists the choice. The icon swaps to Sun in dark mode (click for light) and Moon otherwise, with an i18n aria-label.

Origin

Custom — Primebrick-written. Uses the shadcn-svelte™ Button and @lucide/svelte Moon / Sun icons.

Usage

Default (mounted in AppTopbar)

Code
<ThemeToggle />

Theme application

The toggle mutates the document root class and localStorage directly — no store is involved.

Code
document.documentElement.classList.toggle('dark', next === 'dark'); localStorage.setItem('pb.theme', next);

First-load fallback

With no saved preference, the OS media query decides the initial theme.

Code
const prefersDark = window.matchMedia?.('(prefers-color-scheme: dark)')?.matches ?? false; apply(prefersDark ? 'dark' : 'light');

Props

Full prop table: see API reference — themetoggle.

Key props: none — ThemeToggle takes no props.

Next steps

  • Component catalog
  • UI stack
  • API reference
Last modified on October 28, 2026
LangSelectSidebarAppLauncher
On this page
  • Purpose
  • Origin
  • Usage
    • Default (mounted in AppTopbar)
    • Theme application
    • First-load fallback
  • Props
  • Next steps
TypeScript
TypeScript