You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/@headlessui-react/README.md
+126Lines changed: 126 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1246,3 +1246,129 @@ function MyListbox() {
1246
1246
|`active`| Boolean | Whether or not the option is the active/focused option in the list. |
1247
1247
|`selected`| Boolean | Whether or not the option is the selected option in the list. |
1248
1248
|`disabled`| Boolean | Whether or not the option is the disabled for keyboard navigation and ARIA purposes. |
1249
+
1250
+
## Switch (Toggle)
1251
+
1252
+
[View live demo on CodeSandbox](https://codesandbox.io/s/headlessuireact-switch-example-y40i1?file=/src/App.js)
1253
+
1254
+
The `Switch` component and related child components are used to quickly build custom switch/toggle components that are fully accessible out of the box, including correct ARIA attribute management and robust keyboard support.
1255
+
1256
+
-[Basic example](#basic-example-3)
1257
+
-[Using a custom label](#using-a-custom-label)
1258
+
-[Component API](#component-api-3)
1259
+
1260
+
### Basic example
1261
+
1262
+
Switches are built using the `Switch` component. Optionally you can also use the `Switch.Group` and `Switch.Label` components.
By default the `Switch` will use the contents as the label for screenreaders. If you need more control, you can render a `Switch.Label` outside of the `Switch`, as long as both the switch and label are within a parent `Switch.Group`.
1289
+
1290
+
Clicking the label will toggle the switch state, like you'd expect from a native checkbox.
Copy file name to clipboardExpand all lines: packages/@headlessui-vue/README.md
+157Lines changed: 157 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1037,3 +1037,160 @@ export default {
1037
1037
|`active`| Boolean | Whether or not the option is the active/focused option in the list. |
1038
1038
|`selected`| Boolean | Whether or not the option is the selected option in the list. |
1039
1039
|`disabled`| Boolean | Whether or not the option is the disabled for keyboard navigation and ARIA purposes. |
1040
+
1041
+
## Switch (Toggle)
1042
+
1043
+
[View live demo on CodeSandbox](https://codesandbox.io/s/headlessuivue-switch-example-8ycp6?file=/src/App.vue)
1044
+
1045
+
The `Switch` component and related child components are used to quickly build custom switch/toggle components that are fully accessible out of the box, including correct ARIA attribute management and robust keyboard support.
1046
+
1047
+
-[Basic example](#basic-example-3)
1048
+
-[Using a custom label](#using-a-custom-label)
1049
+
-[Component API](#component-api-3)
1050
+
1051
+
### Basic example
1052
+
1053
+
Switches are built using the `Switch` component. Optionally you can also use the `SwitchGroup` and `SwitchLabel` components.
import { SwitchGroup, Switch, SwitchLabel } from "@headlessui/vue";
1074
+
1075
+
export default {
1076
+
components: {
1077
+
SwitchGroup,
1078
+
Switch,
1079
+
SwitchLabel,
1080
+
},
1081
+
setup() {
1082
+
const switchValue = ref(false);
1083
+
1084
+
return {
1085
+
switchValue,
1086
+
};
1087
+
},
1088
+
};
1089
+
</script>
1090
+
```
1091
+
1092
+
### Using a custom label
1093
+
1094
+
By default the `Switch` will use the contents as the label for screenreaders. If you need more control, you can render a `SwitchLabel` outside of the `Switch`, as long as both the switch and label are within a parent `SwitchGroup`.
1095
+
1096
+
Clicking the label will toggle the switch state, like you'd expect from a native checkbox.
0 commit comments