This is a migrated thread and some comments may be shown as answers.

Long custom labels

3 Answers 290 Views
Switch (Mobile)
This is a migrated thread and some comments may be shown as answers.
Chiefs IT
Top achievements
Rank 1
Chiefs IT asked on 03 Oct 2014, 03:50 PM
Is it possible to have onLabel and offLabel that is longer than three characters?  I'm using the mobile switch on a web page with the silver theme and it appears that if I make the labels more than three characters it bleeds over into the other label.  Try it out yourself click on the "Edit this sample" button here http://demos.telerik.com/kendo-ui/switch/adaptive and change the onLabel or offLabel to "XXXXXXXX" or something long and you will see what I'm talking about.  What I'm trying to accomplish is to get rid of the corresponding labels that you would put next to the control and just show that toggled text in the control itself.  For example I want a switch with the onLabel="Edit Mode" and offLabel="View Mode".

3 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 07 Oct 2014, 08:25 AM
Hi Bob,

This can be achieve with some custom CSS rules, that will make the switch wider, so longer text is shown. I have created an example that shows the implementation, please check it out and let me know if it helps:

http://jsbin.com/pujug/1/edit

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ezequiel
Top achievements
Rank 2
answered on 06 Feb 2018, 05:53 PM

I have one switch on a page and another in a popup window.

Only this one in pop up window I need to have longer labels.

How can I do to apply only to this one?

your sample code is already only at the pop up window.

<input id="approval-switch" data-bind="checked: IsApproved" />
            <style scoped>
                .km-switch {
                    width: 8.2em !important;
                }
 
                .km-switch-background {
                    background-position: 0em 4em !important;
                    width: 8.2em;
                }
 
                .km-switch-label-on {
                    left: -400%;
                }
 
                .km-switch-label-on,
                .km-switch-label-off {
                    white-space: nowrap;
                }
 
                .km-switch-label-off {
                    left: 25px;
                }
 
                .km-switch-label-on {
                    right: 20px;
                }
            </style>

 

 

0
Stefan
Telerik team
answered on 08 Feb 2018, 08:07 AM
Hello, Ezequiel,

In order to modify only one of the switches, I can suggest making the CSS selectors more specific.  For example, adding the switches containers in the selectors:

.popup-container .km-switch {
  width: 8.2em !important;
}
// other styles

I hope this is helpful.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Switch (Mobile)
Asked by
Chiefs IT
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Ezequiel
Top achievements
Rank 2
Stefan
Telerik team
Share this question
or