sterling-svelte  2.0.0
A modern, accessible, lightweight UI component library for Svelte.

Switch

A toggle button between two states.

Code
<script lang="ts">
  import { Switch } from '@geoffcox/sterling-svelte';
</script>

<Switch offLabelText="Off" onLabelText="On" />

Members

Property NameTypeDefaultComment
offLabelstring | LabelSnippet | undefinedundefinedThe text or snippet to display for the off position.
onLabelstring | LabelSnippet | undefinedundefinedThe text or snippet to display for the on position..
verticalboolean | null | undefinedfalseWhen true, the switch is displayed vertically.

Types

Type NameDefinitionComment
LabelSnippetSnippet<[{ checked: boolean | null | undefined; disabled: boolean | null | undefined; inputId: string; }]>

Considerations

  • Includes HTMLInputElement props, events, and methods.

Anatomy

switch (<div>)
  hidden (<input>)
  off container (<div>)
    offLabel (string | Snippet)
  toggle (<div>)
    thumb (<div>)
  on container (<div>)
    onLabel (string | Snippet)