StellarUI

<stellar-switch>

Properties

Preview

Markup

Copy
<stellar-switch
  checked
  label="Email alerts"
  description="Send a notification for new activity."
  prefix-label="Off"
  suffix-label="On"
  prefix-icon="mdi:weather-night"
  suffix-icon="mdi:white-balance-sunny"
  value="on"
>
</stellar-switch>

API

Complete props, events, slots, and implementation notes for the shipped switch.

Props

PropTypeDefaultNotes
toneneutral | primary | secondary | tertiary | errorneutral
sizexs | sm | md | lg | xlmd
orientationvertical | horizontalvertical
labelstring''
descriptionstring''
errorstring''
checkedbooleanfalse
indeterminatebooleanfalse
disabledbooleanfalse
prefix-labelstring''
suffix-labelstring''
prefix-iconstring''
suffix-iconstring''
valuestringon

Events

EventSourceNotes
changehostRedispatched from the inner native checkbox.

Slots

SlotNotes
labelOptional content above the control. Overrides the label prop when present.
descriptionOptional helper content below the control. Overrides the description prop when present.
prefix-labelOptional rich label content before the switch track. Overrides the prefix-label prop when present.
suffix-labelOptional rich label content after the switch track. Overrides the suffix-label prop when present.
prefix-iconOptional icon/content before the switch track. Overrides the prefix-icon prop when present.
suffix-iconOptional icon/content after the switch track. Overrides the suffix-icon prop when present.
errorOptional validation message below the control. It replaces description while the inner control is invalid.

Notes

  • The public tag is `stellar-switch`, backed by a real native `<input type="checkbox">` inside the component.
  • `label` and `description` match the rest of the StellarUI field-control family, and `orientation` controls whether the label sits above or inline with the switch.
  • `prefix-label` and `suffix-label` add optional text beside the switch track; `prefix-icon` and `suffix-icon` render inside their matching label, and matching named slots override prop fallbacks when richer markup is needed.
  • `required`, `aria-invalid`, and `custom-validity` forward to the inner native checkbox for validation-sensitive flows.
  • The host exposes `setCustomValidity()`, `checkValidity()`, `reportValidity()`, `validity`, `validationMessage`, and `willValidate`, so app code can use native-like validity APIs on the custom element.
  • For Datastar, prefer `data-attr:custom-validity="..."` on the custom element host instead of the Pro-only `data-custom-validity` attribute.
  • `checked`, `disabled`, and `value` mirror native checkbox semantics, while `indeterminate` sets the native property after render.
  • The host redispatches `change` so outer Datastar listeners can treat it like a normal form control.
  • The size ramp follows the shared selector sizing so the switch stays close to the checkbox/select control family.