Reverse Engineer the Sencha FontAwesome package to get an overview of icons.

Posted on in CSS Sass

Ext JS 6, ships with a copy of the font-awesome icon font.
Remember the Wingdings* Font from back in the days? Icon Fonts are somehow similar like that. An icon font is a (fontface) font, and every (unicode) character maps to an icon. Icon fonts are great, because they are all vectors. Therefore you can easily change the color or size, and they will always have best quality. Perfect on retina displays. You no longer need to open Photoshop to modify the icons. Because it’s text, you can add shades, change colors, backgrounds and sizes all with CSS code. (You just can’t make 3D icons / multi color icons, because it’s text.). Also, icon fonts won’t spam your screenreaders.


In Ext JS 6, font-awesome icon font is a code package, which is included in the SDK, and free to use. It’s version 4.4. which includes 585 vector icons!

You can use font packages, by enabling font awesome in your app.json file:
(when you generated the application with Sencha Cmd, this should be already there.)

"requires": [

Now you can start using the font, by adding the iconCls property to your component. For example:

   xtype: ‘button’,
   iconCls: ‘x-fa fa-globe’

The iconCls is supported on: buttons, panel titles, menu’s, tree node items, grid actions, separators and ux status bars. (That probably covers most of the places you want an icon for, but if you want icons in for example templates, you can use the below trick as well, and set icons manually.)

The big question is, how do I know, which icons are included out of the box? The easy answer is, you can use the font awesome cheatsheet:
Everything 4.4 and below will be available.

But the best answer is, you can reverse engineer this from the package yourself!
Browse to: myapp/ext/packages/font-awesome/sass/etc/


Let’s first dive into: _variables.scss. This Sass file, shows the font version number, and the CSS prefix. For Ext JS 6.2 this is:

$fa-version: "4.4.0" !default;
$fa-css-prefix: fa !default;

The _variables.scss file sets all the used variable names for every icon. However, we still don’t know how the icon will look like. Therefore, open your browser and use the Icomoon font app:

Click the Import Font button. Now browse to myapp/ext/packages/font-awesome/resources/fonts/ and select: fontawesome-webfont.svg

This will import all the font-awesome icons, which are in Ext JS. Within the Icomoon app, select all the font-awesome icons. (Select the first, hold shift and select the last.)
Then press the Generate Font button in the bottom of the app. You will now see an overview of all the icons with its used unicode. (If you want, you can download the font here, so it also saves an HTML file, with this overview.)

Ok, so now we know how the fonts look like, and what it’s unicode is. I could now, look into this list, pick the icon that I want. Copy the unicode, and lookup the variable name in _variables.scss. For example, the icon with the double music notes, has the title: uniF001, so unicode: *\f001*, which matches Sass variable name: $fa-var-music.

Once you know the variable name, copy it and open _icons.scss. Search in this file for the variable name, and it will reveal to you. For the $fa-var-music variable, it contains this Sass line:

.#{$fa-css-prefix}-music:before { content: $fa-var-music !important; }

Which will be compiled as the following CSS:

.fa-music:before { content: $fa-var-music !important; }

As you can see the CSS class fa-music, will create another node in your HTML DOM, before the element that has this CSS class, with the content that contains the unicode of the music note icon. iconCls, just adds this node in the DOM tree.

How does it know how to style the icon (for example, the color and its font-size?) That’s what the class .x-fa is for.

Note: The x-fa class should be used in Ext JS applications instead of fa which is the class you get if you download the font package from itself. The fa class sets some properties that may collide with the Sencha theme properties, whereas x-fa sets only the font-family:

.#{$prefix}fa:before {
    font-family: FontAwesome !important;

The default font-size and colors are set in _variables.scss:

$fa-font-path:        "../fonts" !default;
$fa-font-size-base:   14px !default;
$fa-line-height-base: 1 !default;
$fa-version:          "4.4.0" !default;
$fa-border-color:     #eee !default;
$fa-inverse:          #fff !default;
$fa-li-width:         (30em / 14) !default;

For the rest it’s up to you to style the icons as you like. You can do this in your theme package or app stylesheet.

*The Wingdings font was developed by Microsoft in 1990, it is actually a dingbat (a printer character used for typesetting) font. None of the characters were mapped to unicode back then, and is only available on (legacy) Microsoft platforms, therefore you should not use Wingdings for the web.


How to Create a Dark Ext JS Theme (part 2)

Posted on in CSS Sass

I’ve been showing you how to develop a fancy dark theme, which kind of looks like Spotify. In Part 1 of the article, you learned about Fashion, Sencha Inspector, Themes, and variables. In Part 2, I’ll focus on more advanced concepts including: making unique components with Ext JS UIs, CSS overrides, and how to incorporate custom fonts or icons.

You can use this tutorial to help you build your theme for the Sencha Application Theming Contest.
The first prize winner gets $2,500!

Sign up now

Custom CSS Rules and Mixins

There are a few more things I did in my Spotifext theme to make it look awesome. I wrote some CSS rules to animate the button hovers, used custom fonts, and created my own button and tab panel variants to give it a unique look.

With the variables I described earlier, you can change the overall look and feel of the application and all its components. But sometimes, you just want to make certain components unique. See the image below of my working Spotifinder app. You can see that the tab panel doesn’t look like the default Ext JS tabs. The buttons can be square or round, in the colors green or gray. I’m using Ext JS UIs, which are Sass mixins under the hood. A mixin is a block of CSS rules that can be re-used throughout an app.

Here’s an example Sass mixin:

@mixin my-border-radius($radius) {
  -webkit-border-radius: $radius;
     -moz-border-radius: $radius;
      -ms-border-radius: $radius;
          border-radius: $radius;

The above Sass mixin can be used to create rounded corners. I need to write experimental browser prefixes, so I can support this CSS3 feature across all browsers. Instead of writing every CSS rule myself, I can just include the my-border-radius mixin and pass in an argument, so all the CSS rules will be available after compilation:

.box { @include border-radius(10px); }

In the compiled CSS, it will look like this (but minified):

.box {
-webkit-border-radius: 10px;
     -moz-border-radius: 10px;
      -ms-border-radius: 10px;
          border-radius: 10px;

Sass mixins are a great concept that can be used in Ext JS as well. We call them UIs, and they’re basically skins. Ext JS includes out-of-the-box UIs. For example, in the modern toolkit, we have UIs for back buttons, round buttons, and more, and it provides UIs you can reuse with your own parameters.

You can find these mixins in the Sencha API Docs. For example, look at Ext.button.Button, you’ll see Sass Mixins in all different states for buttons. To implement these mixins, you’ll use @include, then the mixin name in Ext JS, and then pass in the arguments.


To create the nice rounded buttons, take a look here.

I used the below mixin code to create a new “scale: small” button. For arguments, I passed in the UI name: “round”, which I used in my view as ui: ‘round’), a font-weight, padding and a background color:

@include extjs-button-small-ui(
    $ui: 'round',
    $font-weight: bold,
    $padding: 5px,
    $background-color: $highlight-color 

You might have noticed that the buttons are animated, and the tab panel that looks like Spotify is a lot different from the provided Ext JS mixins. Take a look at my sass/src folder. In this directory, I’ve written all Ext JS mixins and custom Sass rules.


Unique Buttons

As you can see in my application, my buttons are more custom than the configuration provided by the API. My app contains code to make smooth animations. On every rollover, the button slowly lights ups. I did this by using custom Sass / CSS code.

Take a look:

.x-btn-round-small {
    &:hover {
      background-color: $highlight-color2;
      -webkit-transition: background-color 2s ease-out;
      -moz-transition: background-color 2s ease-out;
      -o-transition: background-color 2s ease-out;
      transition: background-color 2s ease-out;

The CSS class names come from the mixin. I gave my small button the ui name: “round”. After I wire up this UI to my view code, I see in my browser DOM that the UI gave the component this class name: .x-btn-‹ui-name›-small.

All Sencha components get CSS class names by default with the .x- prefix. After that, it names the component (btn), then the UI name. For a button, it will also include the scale – or, if it’s in a toolbar. See mixin extjs-button-toolbar-small-ui.

The custom code I provided listens to the button hover. When I roll my mouse over the button, it will transition the background-color from the default background color (in my case black) to a new color (the green that I set in the background-color rule).

Unique Tabs

Sometimes you don’t want to use custom CSS code to add more functionality but instead to override the default look and feel. For example, when the UI mixin doesn’t provide the configuration you are looking for.

I did this to create unique-looking tabs. See the screenshot:

The code I used can be found here. Take a look at the .x-tab-bar-alternative CSS class.

You may be wondering when to use UI mixins versus mixins. UI mixins are great because they style the full application and contain code that supports every browser supported by Ext JS. The disadvantage is that your stylesheet code will grow. This is why I typically use UI mixins for styling, and rules that are re-used throughout my application.

CSS rules and overrides are great because they can be a quick solution. The disadvantage is that it’s complicated because you’ll need to test across browsers, and you really need to understand the generated DOM. I use CSS overrides and rules in case the UI mixin doesn’t provide the configuration, or when I need the CSS rule in only a few places.

Incorporating Fonts

The last thing I did in my custom theme was incorporate custom fonts and icons (which are icon fonts). Please take a look at this file.

I included two custom fonts. One google font (from the Google font provider), and one icon font called Spotifinder that I created on this website. I selected my own icon set, and I generated a font out of it.

Both fonts are @font-face fonts, so you have to include the different font extensions for various browsers in your stylesheet. For the icon font, I had to put them in manually. See the four font extensions. Usually when you create a custom icon font on an icon website like icomoon, you’ll be able to download the stylesheet that goes with it. In my case, I could just copy & paste it, but in some cases you’ll have to write it yourself.

The google font was really easy because Sencha provides a global UI mixin. This mixin puts the code for all the extensions in your compiled CSS code by importing the code from Google. See the docs. Please note that using custom fonts from a font provider (like Google Font) requires an additional request to the font. An alternative way to do it is to download an @font-face font yourself (from a website such as and provide the full import code yourself. Just like I did for the icon font.

Once your font is correctly imported, you can start using it. I’m using the Google font by pointing the $font-family variable to it here.

That’s it! Now, I’ve explained everything you need to know to create an awesome theme, such as the Spotifext theme. Check out the screenshot below to see how it might look in a real-life application.

Don’t forget to sign up for the Sencha Application Theming Contest. The first prize winner gets $2,500!

Spotifext theme


Ext JS Theming Guide
My SenchaCon Presentation
Tutorial Demo Files

How to Create a Dark Ext JS Theme (part 1)

Posted on in CSS Sass


Every now and then, I demo my Spotifinder Ext JS app. It’s a really cool app that connects to LastFm and Spotify. I created it, to demo Ext JS concepts in my training classes. It also shows off the great theming capabilities in Ext JS.

This year, I presented advanced theming at SenchaCon and I received lots of questions about how I created the Spotifinder app theme. So I decided to write a tutorial on how to create a really cool, good looking dark theme.

You can use this tutorial to help you build your theme for the Sencha Application Theming Contest.
The first prize winner gets $2,500!

Sign up now

The tutorial files I used for this tutorial can be found here. It’s basically just a simple Ext JS app (view) with many components, like a grid, and some other components. You can use any other Ext JS (4, 5 or 6) application as well, but I used this as a reference point, and I used Ext JS 6. What’s great about theming an “all-component” -app, is that you see on the fly how your new theme looks like, without clicking through a real-life app.

Another prerequisite: Sencha Cmd needs to run on your command line. Test with this command: sencha which. It should output a version number – for Ext JS 6, the Cmd version should be 6.x.

Neptune theme

Ext JS themes use Sass, which stands for syntactically awesome stylesheets, and yes, it’s indeed awesome. Its a more dynamic way to write CSS code. For example, you can use variables and calculations in your stylesheets. A browser doesn’t understand Sass, only CSS. Therefore, these Sass themes need to be compiled to production-ready CSS code, so your browser can understand it. The compilation process of themes in Ext JS apps runs via Sencha Cmd.

Ext JS ships with a couple of out-of-the-box themes. You can directly switch to one of these themes and use it, or you can extend one of them and modify it. That’s how you create custom themes. The best theme to modify is Neptune or the new Triton. It provides lots of variables you can use to change the look and feel, and because it’s color background and white text on the front, it’s the ideal theme to use to create good looking dark themes. Alright, enough theory, let’s try it out.

Triton theme
Crisp theme

We’ll start by generating a new theme. We’ll just generate a theme package, so you can reuse it in other projects.

Open Sencha Cmd and run the following command:

sencha generate theme theme-spotifext

This will generate a theme package, in my workspace packages/local folder. It will contain a sass/var folder, which will contain a Sass stylesheet with variables. It will be first in the compile order), and it will also contain a sass/src folder, which is the folder that contains Sass stylesheets with mixins and CSS rules. These files will be compiled last, so the pre-defined variables are used. The theme package also contains a resources folder – it can be handy to save assets such as images or fonts in this folder. The package will also contain a package.json file. It has meta info for your theme package. For example, it sets the type of the package to a “theme”. Also, you can write your contact information and description. There is one thing here that you’ll need to change. To create a theme variant of the new Triton theme, change the extend line to:

    "extend": "theme-triton",

Note that themes in Ext JS 6 don’t have the "ext-" prefix anymore.

Now, to see your variant of the Triton theme in the theming demo app, you need to wire it up the correct way.

Switching Themes

I mentioned “the correct way” on purpose because in traditional web design you would change stylesheets by opening the index.html page and swapping the ‹style› tags. It doesn’t work like this in Ext JS applications – you swap your themes via the app.json file. What’s happening here is that the Ext JS microloader loads the correct stylesheet for you, via the bootstrap.css file, which is included in your index.html. The bootstrap.css points to a CSS build version of your Sass theme. This way of serving themes has a huge advantage; all your paths to images and fonts will be all the same across any environment: development, test, or production.

You can wire up your new Spotifext theme by opening app.json of the demo app and changing the "theme" line to:

"theme": "theme-spotifext"

The next step is to build your application with sencha app build or sencha app build development (which only builds the theme instead of the full app), and you’re good to go.
In case you’re running a universal app and you want to use the Spotifext theme for the classic toolkit, you should wire up the theme to a build profile. For example:

"builds": {
   "myclassicprofile": {
      "toolkit": "classic",
       "theme": "theme-spotifext"
   "mymodernprofile": {
      "toolkit": "modern",
      "theme": "theme-cupertino"


The first thing you’ll need to do is create some files. You can create the following file structure, in your package folder (packages/local/theme-spotifext):


Notice the naming of the files. Everything, except _config.scss, maps to the framework components. Component.scss – > Ext.Component, and grid/Panel.scss to Ext.grid.Panel.scss. This mapping is set up in the app.json file as a sass namespace. You don’t need to change that.

An important feature of Sass is the ability to define variables. Do you remember when you used to use plain old CSS? You coded a full stylesheet and by the end of the week someone in your company wanted you to change one of the application colors. It was a huge problem because you had to find and replace all those color values, including all the color codes with lighter or darker contrasts.

With Sass, this is not a big deal anymore. You just define a variable at the top of your file. Later in your CSS rules, you point to those pre-defined variables. Because a Sass stylesheet is compiled, it makes your stylesheet a lot more dynamic.

Try this out. In the Component.scss file, you will include your own color configuration sheet (that’s the _config.scss file). Just write the following line at the top of var/Component.scss:
@import ‘_config.scss’;

Now in the _config.scss file, define a couple of vars which you can use though the full stylesheet. You can define these variables at the top of the file:

//my own variables
$dark-bg: #000;
$dark-bg2: #121314;
$dark-bg3: #222326;
$dark-bg4: darken(#88898C, 15%);
$front-color: #adafb2;
$front-color2: #fff;
$highlight-color: $base-color;
$highlight-color2: lighten($highlight-color, 20%);
$highlight-color3: darken($highlight-color, 20%);
$font-family: 'Montserrat', helvetica , arial , verdana , sans-serif;
$font-size: 12px;

Note the $highlight-color2 and 3, these use built-in Sass functions to change the highlight-color to a 20% lighter or darker tone of the color.

We understand that Sass variables are an extremely important feature of Sass, so Ext JS uses Sass variables as well. There are actually two types of variables: Global variables and Component variables.

Global Variables

The first variable you’ll set is the $base-color – it’s a global Ext JS Sass variable. When you change this variable, it will affect everything in the global scope. Many other colors will be calculated based on the $base-color.

You can find all the Global variables in the API docs by searching for Global_CSS. Or, even better, you can use Sencha App Inspector – see below for more information.

For your theme, you can use these global vars and put them in var/Component.scss:

$base-color: #639000;
$body-background-color: $dark-bg3;
$color: $front-color;
$enable-font-smoothing: true;

Component Variables

Inside Component.scss, I have set a bunch of component variables too. Take a look at my files in the packages/local/theme-spotifext/sass/var/ folder in Git.

I moved some of these component variables to their own scss file, as I did for grid/Panel.scss. That’s just so I can maintain smaller files. By using variables, you’ll notice that I styled about 80% of my application, and I don’t have any problems with CSS overrides. You can find Component Sass variables in the API docs for the component you want to style. For example, search for grids and then click on the CSS vars button. There are a lot of variables to choose from. Before Ext JS 6, you had to use trial and error. But, with Ext JS 6 and App Inspector, it’s a piece of cake to figure out which variable you should use.


Sencha Inspector

Sencha Inspector is a new stand-alone tool. With this tool, you’re able to inspect your Ext JS code, including your MVVM patterns. You can inspect applications, running in any browser or device, even apps that are running in Sencha Web Application Manager.

Not only are you able to inspect your JavaScript code, you can inspect all your Ext JS Sass variables. Together with Fashion, the new way of compiling Ext JS Styleheets, this is super powerful.

For this tutorial, you can try out the awesome theming feature. Download Sencha Inspector Early Access version.

When you search for an Ext JS 6 component in the theme panel, it will expose all the available Sass variables. This will save you from manually browsing through all the docs.

Theme panel

With Fashion (read more below), you can enter values for all these variables, and you’ll see the result immediately on your screen. This is great for testing when you don’t know which Sass variable you need to use. Because you no longer need to wait for app builds or theme compilations, this really speeds up your theme development time. I work with my IDE and Inspector on one screen, and my application running in a browser on another monitor. As soon as I find the right Sass variable with Sencha Inspector, I copy it over to my theme package.

Take a moment and browse through the sass/var code in my package on Github. Within a couple of hours, I finished 80% of my theme.

To get this up and running, you’ll need to have Inspector installed along with Sencha Cmd.
See the docs.

Within Sencha Cmd, you’ll run the built-in webserver (it’s a Jetty web server).

Open Sencha Cmd and run the following command:

sencha app watch

After sencha app watch starts the web server (by default it’s on port 1841), Sencha Cmd polls for changes. Next, open the following URL in your browser:


Once the app is loaded and finishes compiling the theme for the first time, you’ll have to copy and paste the following bookmarklet in your browser console to create a connection between App Inspector and your app.

javascript:!function(a,b){var a=a||3e3,b=b||"http://localhost",c=b+":"+a+"/inspector.js",d=function(a,c){var d=document.createElement("script");d.type="text/javascript",d.src=a,document.addEventListener("load",function(){"undefined"!=typeof Ext&&"undefined"!=typeof Ext.onReady&&Ext.onReady(function(){if(window.SenchaInspector){var a=document.head.getAttribute(“data-senchainspectorport");SenchaInspector.init(b+":"+a)}})},!0),c?document.head.insertBefore(d,document.head.firstChild):document.body.appendChild(d)};document.head.setAttribute("data-senchainspectorport",a),d(c,!0)}();

If you’re interested in what’s going on under the hood, App Inspector uses WebSockets. The App inspector script is running on port 3000. That’s how the standalone app can inspect your application code. Now, we’ll look at compiling the themes.

Sencha App Inspector


I mentioned the word Fashion above. And no, I am not talking about the latest style of clothing. This is a new way of compiling themes that is built into Sencha Cmd.

To compile a theme in Ext JS, you use Sencha Cmd and run either:

sencha app build [development]
sencha app watch [toolkit]

The difference here is that watch is polling for changes, and compiles on the fly, while sencha app build only compiles manually once.

In older versions of Ext JS and Sencha Touch, the Sass stylesheets were compiled on top of Ruby (on Windows, you had to install Ruby with administrator rights). Once everything was set up, you could start compiling the themes, but that compilation took a lot of time – especially when you had a large codebase and an advanced theme. You can see why I am so happy about Fashion.

With Fashion, you can compile your themes on top of JavaScript. It’s so fast that when I change a line of code on my left monitor, it’s already changed on the right monitor before I can turn my head. I don’t need to wait for the compilation (except when starting the server), and I don’t need to refresh my browser window.

The magic all happens under the hood. Sencha Cmd is running PhantomJS in the background, which is basically a headless browser that you can run from the command line. It will run your application, compile the theme, and put it all into one big JavaScript function. Every change you make – whether it’s in your IDE/editor, in the classic or modern toolkit, or with Sencha Inspector – is handled by JavaScript which changes the styling in the DOM. There are many more advantages. For example you can extend on top of Fashion and create your own styling functions (like Sass functions), and you can debug your stylesheet code. You can see these the big advantages on your development machine while you’re designing your theme.

To get this up and running, you’ll need to run sencha app watch classic from your command line and run the following arguments in your URL: ?platformTags=fashion:true and then you are good to go:


Coming Up

There are a few more things I did in my spotifext theme to make it look awesome. I wrote some CSS rules to animate the button hovers, used custom fonts, and created my own button and tab panel variants to make it look unique.

In part 2 of this article, I will explain mixins versus css overrides as well as fonts and icons.

With this information, you should be able to create good looking themes.

Sign up for the Sencha Application Theming Contest. The first prize winner gets $2,500!

Dark theme
Dark theme


Sencha Theming Guide
My SenchaCon Presentation
Download Sencha App Inspector Early Access
Tutorial demo files

How to Style Apps with Fashion in Ext JS 6

Posted on in Ext JS 6 Sass Sencha

In Ext JS 6, one of the big new features is the merged framework. With a single codebase, you can create the best performing applications, with the ideal experience on each device. It also includes a new way to style your apps.

In this article, I will focus on Sencha Fashion – what it is and what you can do with it. Keep an eye out for my upcoming tutorials that will show you how to create a great looking dark theme.

Compiling themes

Themes in Ext JS apps use Sass. It’s a more dynamic way of writing CSS code. For example, you can use variables and calculations in your stylesheets. A browser can’t understand Sass, only CSS. Therefore, these Sass themes need to be compiled to production-ready CSS code, which is what a browser can understand. The compilation process of themes in Ext JS apps run via Sencha Cmd:

sencha app build [development]


sencha app watch [toolkit]

The difference here is that watch is polling for changes, and compiles it on the fly, while sencha app build compiles it manually just once.

In older versions of Ext JS and Sencha Touch, the Sass stylesheets were compiled on top of Ruby. On Windows, you had to install Ruby with administrator rights. Once everything was set up, you could start compiling the themes. But that compilation took a lot of time especially when you had a large codebase and an advanced theme.

To compile an advanced theme, it sometimes could take a minute. Then, you had to refresh your browser window and test it to make sure you set the right Sass variables. And then you had to start over again. You can understand that this process was time consuming. That’s why I am so happy about Fashion.

With Sencha Fashion, you can compile your themes on top of JavaScript, and that is super fast. It’s so fast that when I change a line of code on my left monitor, it’s already changed on the right monitor when I look. I don’t have to wait for the compilation (when starting the server), and I don’t have to refresh my browser window.

Because Fashion is JavaScript, there are more advantages. For example you can extend on top of Fashion and create your own styling functions (like SASS functions), and you are also able to debug your stylesheet code.

However, the big advantage here is on your development machine while you’re designing your theme. To get this up and running, you will need to run sencha app watch from your command line and run the following arguments in your URL and then you’re good to go:


Let’s Compile

You can try to compile a theme with Fashion. First of all, download Ext JS 6. This includes the SDK. You will also need to download Sencha Cmd 6.

After installing the command line tools, extract the Ext JS 6 framework zip somewhere on your machine. Open your command prompt and navigate to the framework folder via the command line. From the Ext6 folder, type the following command to generate your first sencha universal app:

ext> sencha generate app MyApp ../path-to-your-project

Open your new universal app project in your IDE or editor. You will notice two new folders: classic and modern. These are the separate toolkit folders. Shared code will be located in the app folder. The classic toolkit folder contains the legacy (desktop) views. The modern toolkit folder contains the modern touch views. The DOM for both toolkits is different, so the styling will also be a little different. That’s why each toolkit folder has a src subfolder for JavaScript code, and a sass folder for all the specific styling.

Open app.json and scroll to “builds” configuration:

    "builds": {
        "classic": {
            "toolkit": "classic",
            "theme": "theme-triton"
        "modern": {
            "toolkit": "modern",
            "theme": "theme-neptune"

You will notice here, that each build profile, has its own toolkit and theme. You will use the new Triton theme for the classic profile, and the Neptune theme (formerly known as the Sencha Touch default theme) for the modern toolkit.

We don’t need to change this for now. Let’s create the following new files:

  • classic/sass/var/Application.scss
  • modern/sass/var/Application.scss

Now, let’s start our Sencha local webserver, and let Sencha poll for changes in the stylesheet.
From the folder where your universal application is located, run the following command:

path-to-your-project> sencha app watch classic

When Cmd is installed correctly, this command should run fine. The built-in sencha server will wait for changes. Your application by default is available on http://localhost:1841
Assuming you are running on port 1841, let’s open our application in the browser:


Wait until your application is done loading. The first time your theme gets compiled, it will take a little longer. Once you see your application, open with your editor:


If you have two monitors, drag your browser window to the other monitor, so you have your editor on one and the browser on the other.

We will change the overall stylesheet to the color black. Write down the following global variable:

$base-color: #000;

As soon as you hit save, you will notice that the style is changed in the browser — not only the header is changed to black, but also all the other styles that extend from the global base color will be black too. For example, double-click on the grid, and you will notice the alert box was changed too.

Feel free to play around with this, change the $base-color to something else. For example a 20% lighter color of the color red:

$base-color: lighten(red, 20%);
Changing the base color

Of course, you can also theme your modern toolkit this way. Run on the command line:

sencha app watch modern

Open the following url in your browser to trigger the modern toolkit:


Change the following file: modern/sass/var/Application.scss:

It’s fast isn’t it! That’s Fashion. The compilation runs on top of JavaScript. The magic all happens under the hood. Sencha Cmd is running PhantomJS in the background. PhantomJS basically is a headless browser, which you can run from the command line. It will run your application, compile the theme, and put it all into one big JavaScript function. Every change you make, you just let JavaScript change the styling in the DOM.

Stay tuned for my theming tutorials.

Creating Theme-Specific Overrides in Ext JS

Posted on in CSS Ext JS Sass Sencha

Ext JS provides a number of functions that make it simple to create and work with classes. It also provides a series of functions to extend or override existing JavaScript classes. This means you can add behaviors and create your own classes, or override the behavior of some functions. In this article, we will show you how to use theme-specific class overrides.

You probably already know how to create an Ext JS class override. For example, you might want to change default behavior or patch the framework. In that case, you would create the class override using this code:

Ext.define('SomeClassName', {
    override : 'Ext.panel.Panel'
    //the override: by default, all panels will have a 200px width
    width : 200 

The first questions that come up are: what do you name this override class and where do you put it. You may be creating a class override that is specific to a theme. Wouldn’t it be nice, to have this JavaScript override bundled together with your custom theme? For example, in your custom theme, all panels should have a box-shadow. Or perhaps, you created an awesome CSS3 animation that will be visible any time you open a popup window. Unfortunately, the old versions of Internet Explorer can’t handle CSS3, so you might want to write a JavaScript fallback. In both cases, the default functionality change is visual. So, where in your file structure can you create these overrides, so they don’t break any other themes?

The trick is the overrides folder. With Sencha Cmd 3.1, it’s possible for applications and packages to save class overrides in the overrides folder. By default, when you generate a (theme) package, it already contains such a folder, and it has been set up to support overrides.

Let’s create a JavaScript fallback. For a simple animation, we will animate the opacity when opening a popup window.

Create the following file structure in your theme package, (let’s assume the name of this package is called: MyTheme ):

> MyTheme
> > overrides
> > > window
> > > > Window.js

This file structure maps to the file structure of the framework for Ext.window.Window.

Let’s define the class:

Ext.define('MyTheme.window.Window', {

This class will override from Ext.window.Window:

Ext.define('MyTheme.window.Window', {
    override : 'Ext.window.Window'

Let’s test if this override works. First, run this from the command-line:

sencha app refresh

At this point, the previous code won’t change any functionality yet. Let’s output a console log as soon as the class is created, and test it in a browser:

Ext.define('MyTheme.window.Window', {
    override : 'Ext.window.Window'
}, function(){
    console.log("Oh yes, my override works!");

Let’s create the custom behavior. This override will add an animation on the beforeshow listener of a window:

listeners: {
    beforeshow: function(mywindow){

The beforeshow listener will create a new animation (Ext.fx.Anim), so first you have to require the animation in your class:

requires: ['Ext.fx.Anim'],

Next, you include the code for creating the animation in the beforeshow event. For now, we will create a very simple animation, which changes the opacity to smoothly display the window (mywindow) from hidden to 100% visibility:

Ext.create('Ext.fx.Anim', {
    target: mywindow, //argument of the beforeshow event
    duration: 1000, //ms
    from: {
        opacity: 0
    to: {
        opacity: 1

Now, you can test if the animation works.

To top it off, let’s create a nice CSS3 animation for the modern browsers as well. We will wrap the Ext JS animation into a check that will only execute when the browser is an old version of Internet Explorer (IE9 or lower):

if(Ext.isIE9m) {

Confirm your code looks like this:

Ext.define('MyTheme.window.Window', {
    override : 'Ext.window.Window',
    requires: ['Ext.fx.Anim'],
    closeAction: 'hide',
    listeners: {
        beforeshow: function(mywindow){
            if(Ext.isIE9m) {
                Ext.create('Ext.fx.Anim', {
                    target: mywindow,
                    duration: 1000,
                    from: {
                        opacity: 0
                    to: {
                        opacity: 1

The only thing that is missing is the Sass code for the CSS3 animation. We will use Compass for that.

In the theme package, we can add the following Sass code to packages/MyTheme/sass/src/window/Window.scss. The code below shows the same animation that we coded in the JavaScript file:

@import "compass/css3/transition";
.x-window.x-hide-offsets {
    @include opacity(0);
.x-window {
    @include single-transition(opacity, 1000ms);
    @include opacity(1);

You will need to compile the Sass stylesheet to production-ready CSS code. Since this is included in Sencha Cmd and the Sencha build process, the Sass stylesheet will be automatically compiled when building the application with Sencha Cmd.

For now, we don’t need to build the whole application, we just want to quickly test the animation and only compile the stylesheet. You can achieve this by running one of the following commands from the command-line:

sencha ant sass


sencha app watch

The first command runs the Apache Ant task to compile the Sass once. The second command is more powerful, but it requires you to download and install Java Development Kit 7. You can compare sencha app watch with the Compass command: compass watch. Sencha Cmd watches the app and every time you hit save, Sencha Cmd builds your app and compiles your Sass Stylesheets. When changes are detected, only the minimum amount of work necessary is performed to bring your app and its CSS up to date, saving you from rebuilding your Sass.

Voila — the animation works in old and new browsers.

If you’d like to learn more about this and many other advanced Ext JS theming techniques, take our Advanced Theming Ext JS course. Check out to join one of the Theme331 Advanced Theming classes located around the world or join an online class.

Getting Started with Sencha Touch 2: Build a Weather Utility App (Part 2)

Posted on in CSS Sass Sencha Sencha Touch

In this three-part Sencha Touch tutorial, you will build the Do I need my Umbrella app, a simple utility app that loads weather information from a web service — Based on weather codes, this app can predict if you need your umbrella or not.

In this second part of the tutorial, you will start to build an app theme. You will use the code from part 1 of this tutorial. You can find the tutorial here.

Here are some additional resources:
You can download the final app code — full solution and stylesheet.
There are some tutorial goodies.
You can see the app itself with the custom theme here.

This tutorial requires:

  • Sencha Touch 2.3 or higher
  • Sencha Cmd 4.x
  • Compass & Sass on top of Ruby
  • A modern browser
  • Editor

Extend from the default theme

You will build a custom theme that is based on the default theme. The default theme is a good theme to extend from, because it has a lot of Sencha Sass variables and mixins, which can be found in the API Docs.

Weather App Tutorial

By default, when generating an application with Sencha Cmd, a resources folder is already generated for you, with an empty Sass stylesheet: app.scss. Let’s open: app.scss

The Sass stylesheet will look like this:

//(1) Define your Sencha variables here

@import 'sencha-touch/default';
@import 'sencha-touch/default/all';

//(2) Define your custom Sass/CSS code and mixins here

In the top (1), you will define all your (Sencha) variables; directly after the variables you will include the mixins. It’s important to keep this order, otherwise the variables won’t have any effect. The imports make use of these variables.

After the imports (2), you can start writing your own custom CSS rules and mixins.

Let’s start very easy and change the base-color:

$base-color: #42282E;

By changing the base-color, you will set a primary color scheme that most of the Sencha Touch components use.

Let’s test it. With Sencha Cmd on the command-line, run the following command: sencha app watch

Sencha Cmd 4 and higher has the command sencha app watch. You can compare this with the Compass command: compass watch. Sencha Cmd watches the app and every time you hit save, Sencha Cmd builds your app and compiles your Sass Stylesheets. When changes are detected, only the minimum amount of work necessary is performed to bring your app and its CSS up to date, saving you from rebuilding your Sass.

Preview your application in a modern browser: http://localhost/dinmu.

Now let’s play around. Sencha Touch has some really good Sass variables and mixins you can use to easily customize your theme. A great tool to get the right color combinations is Adobe Kuler. Go explore some populair color schemes:, and let’s use these as the color variables for Do I need the Umbrella app.

Let’s set the colors for the buttons, alert box, and both screen backgrounds (settings and main):

$alert-color: #D6665A;
$confirm-color: #75A48B;
$page-bg-color: lighten(#D9CFB0,15%);
$form-bg-color: $page-bg-color;

Also, let’s get rid of all the gradients:

$base-gradient: 'none';

The bottom toolbar has the ui: ‘light’. Let’s create a mixin to style the light skin of the bottom toolbar. You can use the sencha-toolbar-ui for this. We can implement it below the sencha imports (2):

@include sencha-toolbar-ui('light', #DC9B74, 'none');

Weather App Tutorial

Create custom CSS

Now let’s implement our own CSS rules.

First, we will modify the toolbar title text:

.title {
    .x-title {
        line-height: 2.5em;
        text-shadow: none;
        letter-spacing: -1px;

Next, let’s position the footer text:

.footer {
    font-size: 0.6em;
    padding: 12px;
    text-align: right;
    letter-spacing: 0;
    a {
        color :#000;

You will also need some styles for the custom template. Let’s modify the font and font colors:

.textview {
    color: black;
    line-height: 1.2em;
    letter-spacing: -1px;
    padding: 0.8em;
    text-transform: uppercase;

    .yes {
        color: $alert-color;
    .no {
        color: $confirm-color;
    .temp {
        color: $confirm-color;

Let’s edit the settings form. In your Sass stylesheet, create the styles to tweak the settings form:

.x-form-fieldset {
    .x-form-fieldset-inner {
        border: none;
        background: $page-bg-color;
    .x-form-fieldset-instructions .x-innerhtml {
        color: #000;

.x-form-label {
    background-color: lighten(#DC9B74, 32%);
.x-toggle-field .x-form-label {
    background: none;
    border: none;
    margin-bottom: 20px;
.x-toggle {
    position: absolute;
    right: 0;

Implement a custom font

Right above the sencha imports, add the imports for the font. We will make use of the Google Fonts service. With this font-service you can browse through lots of hosted font families and choose a font to implement:

@import url(;
@import url(;

Now, set the fonts.

For the toolbar title, add the following rules to the .x-title CSS class:

font: {
    family: "Lobster";
    size: 1.2em;

For the template view, add the following rules to the .textview CSS class:

font: {
    family: "Oswald";
    size: 2em;

Tweak the performance

If you want to optimize your Sencha Touch application for performance, optimizing your Stylesheet is probably the easiest thing to do; and it's very effective. Let’s reduce the file size of the compiled CSS stylesheet.

Automatically, when you generated your app with Sencha Cmd, the compiled CSS stylesheet was minified. This works because of the output_style setting in the resources/sass/config.rb file. Would you rather have the output readable? Set the output_style value to :expanded, but note, your file size will grow.

Check the resources/sass/config.rb file, it should be set like this:

output_style = :compressed

Instead of importing all Sencha Touch framework mixins, let’s only import the ones that are absolutely necessary. This will reduce the stylesheet size, so it will be faster to download.

I usually comment out the @import line that imports all the mixins. Then, I list all the Sencha Touch mixins myself, and I make sure Sencha Cmd is watching/compiling my Sass file (sencha app watch).

Then I start to comment out the mixins one by one, based on the classes I don’t use. This is tricky though; there are classes that you may have never directly coded, but they are subclasses from other classes, such as +Class+ or +Panel+. That's why you should remove them one by one, while watching your terminal to see that you don't get any compile errors. The list of all the available Sencha Touch mixins can be found in: touch/resources/themes/[theme-to-extend-from]/all.scss.

Replace @import ‘sencha-touch/default/all’ with the following imports:

@import 'sencha-touch/default/src/_Class.scss';
@import 'sencha-touch/default/src/_Button.scss';
@import 'sencha-touch/default/src/_Panel.scss';
@import 'sencha-touch/default/src/_MessageBox.scss';
@import 'sencha-touch/default/src/_Toolbar.scss';
@import 'sencha-touch/default/src/carousel/_Carousel.scss';
@import 'sencha-touch/default/src/form/_Panel.scss';
@import 'sencha-touch/default/src/form/_FieldSet.scss';
@import 'sencha-touch/default/src/field/_Field';
@import 'sencha-touch/default/src/field/_Checkbox.scss';
@import 'sencha-touch/default/src/field/_Select.scss';
@import 'sencha-touch/default/src/field/_Slider.scss';
@import 'sencha-touch/default/src/field/_Spinner.scss';
@import 'sencha-touch/default/src/picker/_Picker.scss';
@import 'sencha-touch/default/src/slider/_Slider.scss';
@import 'sencha-touch/default/src/slider/_Toggle.scss';

We are not using many icons, so there is no need to implement the Pictos icon font. In this case, let’s just use our own icon font, so we can save some extra kilobytes.

Add these variables to the top of your Sass stylesheet right before the import of the Sencha mixins:

$include-pictos-font: false;
$include-default-icons: false;

Now, you will include a custom icon font. I created an icon font via the IcoMoon website: It’s in the goodies-tutorial folder of this tutorial. Just copy the dinmu fonts folder over to resources/sass/stylesheets/fonts/.

Underneath the imports of the google font, import the dinmu icon font:

@font-face {
    font-family: 'Dinmu';
    src:url('stylesheets/fonts/dinmu/Dinmu.eot?#iefix') format('embedded-opentype'),
        url('stylesheets/fonts/dinmu/Dinmu.ttf') format('truetype'),
        url('stylesheets/fonts/dinmu/Dinmu.woff') format('woff'),
        url('stylesheets/fonts/dinmu/Dinmu.svg#Dinmu') format('svg');
    font-weight: normal;
    font-style: normal;

Below all the imports, create an icon mixin, to display the settings button:

@include icon('settings', 's', 'Dinmu');

Directly after that, you can code some funny icons for the template view:

.norain:before {
    font-family: 'Dinmu';
    speak: none;
    font-style: normal;
    font-weight: normal;
    font-variant: normal;
    text-transform: none;
    line-height: 1;

    padding-right: 10px;
    font-size: 60px;

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

.norain:before {
    content: "53";
    color: $confirm-color;
.rain:before {
    content: "52";
    color: $alert-color;

Finally, the Do I need my Umbrella theme is finished! Open your browser and run: http://localhost/dinmu.

Weather App Tutorial

The next steps for improving your application would be to create a production build and port this app to a native PhoneGap app. These topics will be discussed in part 3 of this tutorial.

Interested in creating Sencha themes? Starting in December, Sencha will start offering advanced Ext JS theming courses. Take a look at the open courses located around the world or join an online training.

Using Custom Icons in Your Ext JS Apps

Posted on in CSS Ext JS Sass Sencha

Do you like the glyph attribute in Ext JS 4.2 as much as I do? With glyphs, you can implement an icon that is created from a font. There are advantages to using icon fonts — they are vectors and therefore never lose quality; it’s easy to style icons without the use of Photoshop; and you make one page request to download all of the icons.

The glyph attribute is available on Ext JS buttons and panels. You can download a custom icon font from a site like: IcoMoon and implement the font in your style sheet. The value of the glyph attribute is the decimal code that maps to the unicode character which represents your icon. You add this attribute to the name of your custom font, and you’re good to go:

glyph: '115@MyIconFont',

A lot of Ext JS components extend from panel, but what if you want to implement icon fonts in other components that do not extend from

To answer this question, we can use the concepts that are actually happening under the hood:

A character is inserted before (or after) a certain DOM element. You can see an icon because this character is styled with a custom font (@font-face technique) that contains all of the icons.

Let’s try this ourselves:

  1. With your browser’s dev tools, select the DOM element in which you want to implement an icon. Ideally put a CSS class on top of it (for example: .arrow), so you can easily refer to it from your Sass.
  2. Download an icon font and map it to some character. (Let's use the following character: >)
  3. Implement the icon font in your Sass:
    @font-face { font-family: 'MyIconFont'; src: url('../resources/fonts/Nouveau.eot'); src: url('../resources/fonts/Nouveau.eot?#iefix') format('embedded-opentype'), url('../resources/fonts/Nouveau.woff') format('woff'), url('../resources/fonts/Nouveau.ttf') format('truetype'), url('../resources/fonts/Nouveau.svg#Nouveau') format('svg'); font-weight: normal; font-style: normal; }
  4. Alright, now comes the magic. In your Sass style sheet, write the following CSS rules:
    .arrow:before { content: ">"; //the character mapped to an icon font-family: 'MyIconFont'; //the name of the icon font color: red; //set additional colors or dimensions... margin-right: 10px; }

The pseudo CSS selector
:beforewill create the icon on the left side of the DOM element. The pseudo CSS selector
:afterwill create the icon on the right side of the DOM element.

Now that you know how to use this technique, you can try it in any components, such as templates, dataviews, form fields, etc.

Create an amazing Sencha Touch theme with SASS

Posted on in CSS Sass Sencha Touch

This tutorial shows you how to build an amazing Sencha Touch 2.1 theme: Like this one.

generate your application with Sencha CMD, so you have the MVC folder structure:
- app
- - model
- - store
- - view
- - profile
- - controller
- resources
- - css
- - sass

  1. Open [project] /resources/ folder
  2. Create the following (new) folders:

- default
- spidey
- - sass
- - css
- - fonts
- - images

Download the zip file below. It contains the full theme including all the asets:
Spidey Theme.

Copy all the assets over from my attached zip; incase your default assets have no subfolder default, copy the original sass, css... folders
over to default. Note for fonts, you will need a fontface kit: .eot, svg, .ttf, .woff)

  1. Create 2 new files in the resources/spidey/sass/ folder: spidey.scss and config.rb
  2. Change the content of the config.rb file to:
# Get the directory that this configuration file exists in
dir = File.dirname(__FILE__)

# Load the sencha-touch framework automatically.
load File.join(dir, '..', '..', '..', 'touch', 'resources', 'themes')

# Compass configurations
sass_path = dir

# Require any additional compass plugins here.
relative_assets = true

fonts_path = File.join(dir, "..", "fonts")
images_path = File.join(dir, "..", "images")
css_path = File.join(dir, "..", "css")

#output settings
output_style = :compressed
environment = :production

Actually what we are doing in this config file, is setting the paths to all your Sencha Touch framework folder and relative paths to your asset folders and CSS folder.
Last but not least there are some settings, to setup the production output of the generated CSS file. In this case the code will be minified.

  1. Incase you changed the folder structure of the default style files, you will need to make sure that it's pointing to the framework folder.
    Since now you are one extra level deep, you will need the sencha-touch framework dir:
load File.join(dir, '..', '..', '..', 'touch', 'resources', 'themes')

Read more on the next page about how to setup your SASS file.