-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to position Switch label to the left of the switch? #11618
Comments
|
I have added the |
Hi, |
I too would like this. imagine that you have a pane to view some page of results, and you want a select all switch at the top right. You want the label on the left to nestle nicely into the top right corner. this is totally in line with mobile first design and hey, bonus! it works on a desktop layout too! I've +1'ed the ticket! Material-UI is a component lib, and regardless if we "think" we would do something, the option to show a form label on one side or the other is ultimately a design decision which a flexible and powerful framework should be able to offer. wink :) |
Alright, we can add a property to change the order of the control and the label: |
@oliviertassinari Any thoughts on prop name? |
@mbrookes Not really, maybe we could follow the Tooltip wording. It's important to have a wording that works with right to left and left to right direction. |
What about: controlPlacement?: 'start' : 'end'; or labelPlacement?: 'start' : 'end'; |
Thanks for repoening :-) Why not make it a boolean? e.g. "controlBeforeLabel" |
Hmm... good point on LTR, although while Tooltip respects the prop wording ( |
@caroe233 So we can accept more values, like top, bottom or center. |
it is compatible with the spirit of a switch:
|
Which release will this be in? |
@kaitlynbrown The next one. 😜 |
What if we want to put labels on both sides? |
@iamkennytso I guess the best answer is: DIY. We try to focus on the most common use cases. |
I've used |
@benmccann This would be better asked on StackOverflow. Stuff to try: text align right, flex justify end. |
The examples here demonstrate how to add a label to various forms of input, including the
Switch
component.Unfortunately, every single example on that page that includes a label has it positioned to the right of the component. I've looked through the props of
FormControlLabel
, and there doesn't seem to be any option that allows me to change this. In fact, looking at the code ofFormControlLabel
, it seems to be hard-coded his way.I was able to work around this by setting the Label's direction to rtl (and setting the Switch's direction back to ltr):
But this feels very hacky and potentially unstable to me.
Is there any way I can have a
Switch
with its label on the left without resorting tortl
hacks? If so, can it please be documented? If not, please consider this a feature request.The text was updated successfully, but these errors were encountered: