ToneSwitch

ToneSwitch enables the user to switch between light and dark modes using a switch control.

<App>
  <AppHeader>
    <SpaceFiller />
    <ToneSwitch />
  </AppHeader>
  <Card
    title="Tone Switch"
    subtitle="Toggle the switch to change the tone."
  />
</App>
Example: using ToneSwitch
<App>
  <AppHeader>
    <SpaceFiller />
    <ToneSwitch />
  </AppHeader>
  <Card
    title="Tone Switch"
    subtitle="Toggle the switch to change the tone."
  />
</App>

Behaviors

This component supports the following behaviors:

BehaviorProperties
Animationanimation, animationOptions
Bookmarkbookmark, bookmarkLevel, bookmarkTitle, bookmarkOmitFromToc
Component Labellabel, labelPosition, labelWidth, labelBreak, required, enabled, shrinkToLabel, style, readOnly
Tooltiptooltip, tooltipMarkdown, tooltipOptions
Styling Variantvariant

Properties

iconDark

default: "moon"

Icon to display for dark mode

iconLight

default: "sun"

Icon to display for light mode

Events

didChange

This event is fired when the user switches between light and dark modes.

Signature: didChange(tone: string): void

  • tone: The new tone value: "light" or "dark".

Exposed Methods

This component does not expose any methods.

Styling

Theme Variables

VariableDefault Value (Light)Default Value (Dark)
backgroundColor-indicator-ToneSwitchwhitewhite
backgroundColor-ToneSwitch-dark$color-primary-500$color-primary-500
backgroundColor-ToneSwitch-light$color-surface-200$color-surface-700
borderColor-ToneSwitch$color-surface-300$color-surface-700
borderColor-ToneSwitch--hover$color-surface-400$color-surface-600
boxShadow-indicator-ToneSwitch0 2px 4px rgba(0, 0, 0, 0.1)0 2px 4px rgba(0, 0, 0, 0.1)
color-ToneSwitch-dark$color-surface-0$color-surface-0
color-ToneSwitch-light$color-text-primary$color-text-primary