Replies: 3 comments
-
Has anyone seen this? @adamwathan |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hey! This is how labels generally work in HTML — clicking the label activates or toggles the associated form control. See this really minimal JSFiddle example: https://jsfiddle.net/s8oL2f6a/ If you don't want that behavior for your switch, set the https://headlessui.com/react/switch#using-a-custom-label ![]() |
Beta Was this translation helpful? Give feedback.
0 replies
-
Cheers for clarifying it. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I noticed that the Switch.Label includes an onClick property, given that a label should be a p or a span tag, why have you added the onClick here?
It can possibly create unwanted behaviours such as this one that I can see on the tailwindui. When the user clicks the label part of the component (ie "Annual billing (Save 10%)"), the toggle button is enabled/disabled.
After a small research, I found out that behaviour is not there if the Switch.Label is encapsulated in another p or span tag, but I am not convinced that this is the best thing to do.
Beta Was this translation helpful? Give feedback.
All reactions