I want to add a small image in the text field in sencha touch. For example a small user icon in the username text field.
Asked
Active
Viewed 1,974 times
1 Answers
5
Create your textfield like this:
{
xtype: 'textfield',
cls: 'username',
fieldLabel : 'Username', // works for ExtJS
label : 'Username' // works for Sencha Touch
}
and add this to your CSS
.username .x-form-text, .username .x-form-field {
background: url(http://upload.wikimedia.org/wikipedia/commons/thumb/1/12/User_icon_2.svg/48px-User_icon_2.svg.png) no-repeat left;
background-size: contain;
padding-left: 25px;
}
.username .x-form-field { /* Adding more padding for Sencha Touch only */
padding-left: 50px;
}

Guilherme Lopes
- 4,688
- 1
- 19
- 42
-
I was looking for something inbuilt. But this looks fine. Thanks.. – user2842237 Oct 19 '14 at 15:00
-
@user2842237 This _is_ the officially supported, builtin how-to-do-it! – Alexander Oct 20 '14 at 08:08