Allow to change component prop of wrapper of Switch component
#8988
AndreiOrmanji
started this conversation in
Feature requests
Replies: 1 comment
|
You can do that with attributes – https://mantine.dev/styles/styles-api/#attributes |
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 want to have my own label component outside of Switch, but no matter if I provide value for label prop or not, label tag is always there and acts as a wrapper for whole Switch component, that we can see from the source code of Switch:

In my case, when I try to add my own label attached to Switch by linking by Switch's id and label's htmlFor prop, I have 2 labels. From a semantics and accessibility standpoint:
Current implementation Switch allows me to override bodyElement prop of InlineInput by passing {component: 'div'} to Switch via wrapperProps, but it would require cast to make TS happy, which is a solution, but I would prefer to not use cast as from used components perspective it is legal and working solution, so only TS has no info about that.
Example:

Expected output:
I would like to have a way to pass a name of component (as for polymorphic components) for wrapper of Switch, or at least somehow to control if there is a
divorlabelfor better accesibility and flexibility.All reactions