loose canon
by Travis Webb
How to Override the Default Sencha Touch 2 Radio Field Style
12:08 am | March 24, 2012

Author: tjwebb | Category: Uncategorized | Tags: , | Comments: 2

Sencha Touch 2.0 is out, and so far everything is going great. A pet peeve of mine, though, is that Ext.field.Radio looks exactly like Ext.field.Checkbox. This is a strange “feature”, and reeks of laziness on Sencha’s part. I have developed my own Radio style that you can feel free to borrow and use however you’d like.

Original Radio style.

Ahh, much better.

I created a separate CSS file called “overrides.css” that I use to override some of the default styles, and put the following CSS in there.

.x-field .x-input-radio:after,
.x-field.x-item-disabled .x-input-radio:checked:after {
    content: "";
    position: absolute;
    width: 1.4em;
    height: 1.4em;
    top: 50%;
    left: auto;
    right: 1.1em;
    -webkit-mask-image: url();
    margin-top: -0.7em;
    border-radius: 15px;
}
.x-field .x-input-radio:checked:after {
    content: "";
    position: absolute;
    top: 50%;
    left: auto;
    right: 1.1em;
    -webkit-mask-image: url();
    margin-top: -0.7em;
    border: 5px solid #dddddd;
    border-radius: 15px;
}
Comments:
  • rdougan

    Nice!

    Looks like we will do something similar in the next version of Sencha Touch.

    Bare in mind though that border-radius will not properly work on Android.

    4:21 pm | March 30, 2012
    • tjwebb

      Thanks for the feedback. border-radius sort of works on Android, but it doesn’t render perfectly. Do you have any suggestions on how I could improve this?

      4:25 pm | March 30, 2012
  • Leave a Reply