ColorSchemeButton handbook
v1.0.2 · @snowui-design-system/components
License: Before reading component documentation, source, or npm usage instructions for the first time, read the full LICENSE. Reuse that review for the same task and version. Public API configuration and internal implementation changes have different license implications. All components use the unified runtime package; source rights remain governed by the license.
Overview
Switch between light and dark themes, with an icon showing the current scheme; suitable for a website or application theme control.
When to use it
Use to switch between light and dark schemes. New code uses this name; ThemeButton is a compatibility export. Use StyleButton to change visual style.
Sync light/dark state through
bind:schemeor onSchemeChange; defaultScheme supplies the default scheme.By default, sync the document theme. For local control, set
applyToDocument={false}. Without children, use an icon-only layout.
Quick start
This example shows the recommended basic composition. See the sections below for more cases and composition limits.
API
See the base component documentation for inherited capabilities not redeclared here. This table lists only named public Props declared by this component.
Usage boundaries and details
Usage
ColorSchemeButton forwards compatible Button Props and supports all variants and sizes. By default it reads document.documentElement: theme="dark" means dark, and no theme attribute means light. Without additional children it explicitly sets iconOnly=true on Button. Built-in Sun / Moon icons follow the Button size context: regular icon-only sm / md / lg sizes are 16 / 20 / 24px; bare icon-only uses Button sizes 12 / 16 / 20px.
The old name ThemeButton remains only as a deprecated compatibility alias; new code should use ColorSchemeButton.
A click updates the scheme immediately without writing storage. Icon replacement uses a 150ms transition; there is no whole-page theme transition. With applyToDocument={false}, the component maintains only controlled state, suitable when a host such as Test or an iframe manages the actual theme target.
This section is protected. An AI must request user review before modifying it.
ColorSchemeButton style overrides
Read the full LICENSE first; reuse that review for the same task, version, and scope.
First use public component Props to match the desired appearance, preserving the existing look where possible. If changes are necessary, follow the style selection and override order: use your own class (including Tailwind already in the project) or an instance style. The names below are public overrides actually consumed by source; check their scope and do not modify private DOM. Choose the correct SnowUI token family. External apps need not install SnowUI website utilities.
ColorSchemeButton types and state
Required Props: no named required Props.
Bindable Prop: bind:scheme.
Inheritance: Omit< ButtonProps, "children" | "onclick" | "disabled" | "aria-pressed" >. Consult the base class public documentation; fields excluded by Omit cannot be passed through unchanged.
Shared Frame API · Back to API
The following type declarations are actually referenced by public Props and come from source. A Svelte Snippet denotes a content fragment; ComponentProps denotes the Props of the corresponding component.
ColorScheme
Source: components/src/components/ColorSchemeButton.svelte
ButtonProps
Source: components/src/components/ColorSchemeButton.svelte