vuetify icon indicating copy to clipboard operation
vuetify copied to clipboard

[Feature Request] Prepend label for switch

Open fr4gst4 opened this issue 6 years ago • 9 comments

Problem to solve

It would be possible to have the text on the left side and the switch itself on the right side

Proposed solution

My suggestion would be to add a prepend-label property so you could decide to have the switch element the default way

switch - label

or

label - switch

fr4gst4 avatar May 24 '19 09:05 fr4gst4

That could apply also for radio and checkbox, and probably better prop name would be "reverse" to be in line with other components

jacekkarczmarczyk avatar May 24 '19 10:05 jacekkarczmarczyk

https://codepen.io/anon/pen/XwEepd

KaelWD avatar May 24 '19 10:05 KaelWD

It's not aligned properly, doesn't have pointer cursor, doesn't toggle value on click and feels like misuse of slots

https://codepen.io/anon/pen/byvoWz

jacekkarczmarczyk avatar May 24 '19 10:05 jacekkarczmarczyk

anything new about it ?

Waynezhi avatar Sep 12 '19 13:09 Waynezhi

This isn't too painful to work around in CSS with the current component, since flexbox can swap the order of the elements. I put together a basic proof-of-concept using the standard label slot with a new class applied to the v-switch and it works fine for my uses.

https://codepen.io/alanaktion/pen/OJPQKdx

It would be nice to see this included in Vuetify natively, especially since most of the switch examples in the Material documentation use this reversed layout.

Alanaktion avatar Jan 08 '20 21:01 Alanaktion

I decided to give it a try. Required a bit of CSS to align stuff properly and I am not sure if it is even clean... I mean the placement of the hint/description/subtitle is problematic. Screen readers will read it like it's just a part of label, clicks change selection state and text cannot be selected.

Guess the suggestion from years ago still stands - to use #prepend instead... The only issue is it expands when the hint is very long.

-- Edit: got it right with grid-template-columns: auto auto max-content; (example). It breaks details section (hints, errors), but hopefully nobody actually uses them under selection controls.

J-Sek avatar Jan 23 '25 22:01 J-Sek

@J-Sek i hope they make the adjustment, may be a pull request will end some pain for RTL languages, thank you for the working example !

benounnas avatar Jan 26 '25 23:01 benounnas

I managed it with custom style

  .v-switch {
    &.--label-left {
      .v-selection-control {
        flex-direction: row-reverse;
        justify-content: space-between;
  
        label {
          padding-inline-start: 0;
          padding-inline-end: 10px;
        }
      }
    }
  }

freddy-daniel avatar Apr 10 '25 07:04 freddy-daniel

Any progress on it?

mikhaylov-ya avatar Dec 08 '25 12:12 mikhaylov-ya