5m
Intermediate
Intermediate experience level
GuidedA passive walkthrough. Just click next to continue.
Style the control
See how a switch gets its color and motion from data-state, including the indeterminate state, and when attrs belong on your own element.
You'll learn how to:
- 1See that the styling is in the example
- 2Watch data-state move the thumb
- 3Color the track from data-state
- 4Move the thumb from data-state
- 5Find the data-state class in the example source
- 6Style data-state instead of toggling a class
- 7See which part sets which attribute
- 8See why data-disabled is true or missing
- 9Style the indeterminate state
- 10Keep aria-checked and data-state separate
- 11Bind slot attrs only on a renderless host
- 12Style the next headless control the same way