Skip to content

Commit e30f7b9

Browse files
committed
switch data attrs
1 parent 080ad15 commit e30f7b9

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

docs/src/routes/components/switch/examples/disabled.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import styles from "./switch-custom.css?inline";
55
export default component$(() => {
66
useStyles$(styles);
77
return (
8-
<Switch.Root class="switch-root" disabled>
9-
<Switch.Trigger class="switch-trigger">
10-
<Switch.Thumb class="switch-thumb" />
8+
<Switch.Root class="ml-4 gap-2 ui-disabled:opacity-50" disabled>
9+
<Switch.Trigger class="w-10 h-6 rounded-full bg-gray-300 transition-colors duration-200 border-none p-0 relative cursor-pointer ui-checked:bg-[#045c88] focus-visible:outline focus-visible:outline-offset-2 focus-visible:outline-[#045c88]">
10+
<Switch.Thumb class="w-5 h-5 rounded-full bg-white top-0.5 left-0.5 transition-transform duration-200 absolute transform translate-x-0 ui-checked:translate-x-full ui-checked:left-[-2px]" />
1111
</Switch.Trigger>
1212
<Switch.Label>Disabled switch</Switch.Label>
1313
</Switch.Root>

docs/src/routes/components/switch/examples/hero.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import styles from "./switch-custom.css?inline";
55
export default component$(() => {
66
useStyles$(styles);
77
return (
8-
<Switch.Root class="switch-root">
9-
<Switch.Trigger class="switch-trigger">
10-
<Switch.Thumb class="switch-thumb" />
8+
<Switch.Root class="ml-4 gap-2 ui-disabled:opacity-50">
9+
<Switch.Trigger class="w-10 h-6 rounded-full bg-gray-300 transition-colors duration-200 border-none p-0 relative cursor-pointer ui-checked:bg-[#045c88] focus-visible:outline focus-visible:outline-offset-2 focus-visible:outline-[#045c88]">
10+
<Switch.Thumb class="w-5 h-5 rounded-full bg-white top-0.5 left-0.5 transition-transform duration-200 absolute transform translate-x-0 ui-checked:translate-x-full ui-checked:left-[-2px]" />
1111
</Switch.Trigger>
1212
<Switch.Label>Enable notifications</Switch.Label>
1313
</Switch.Root>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Hero from "./examples/hero";
2+
import Disabled from "./examples/disabled";
3+
4+
# Switch
5+
6+
A Switch is an interactive button that works like a modern light switch - it smoothly slides between two states: ON and OFF.
7+
When interacting with it, the switch's thumb (the moving part) slides from one side to the other, giving clear
8+
visual feedback about whether something is enabled or disabled. It provides a visual representation similar to a
9+
physical switch and is commonly used for enabling/disabling settings or features.
10+
11+
## Basic Usage
12+
13+
<Hero />
14+
15+
## Disabled
16+
17+
<Disabled />

0 commit comments

Comments
 (0)