General Calendar Cards Color Date & Time Event Calendar Forms Grid Layout Image Listview Measurement Navigation Number Numpad Option List Page Popup Range Scroller Scrollview Select Timer Timespan Treelist Tools Accessibility

Customizing the Look and Feel

Introduction

Mobiscroll components are shipped with a ready-to-use, carefully crafted design, with the ability to adapt to the platform where they are being used. The available themes are:

The Mobiscroll package is shipped with a pre-built css file, once it's added to your project, the bundled themes can be used right away.

While the provided pre-built themes are enough in many use cases, most of the times on top of adapting to a specific platform, you'd also like to match a brand or color scheme. Mobiscroll provides various ways to achieve this:

To work with the first two methods, you need to have Sass support configured for your project.

If you're not using the tools above, you can use any existing Sass tooling to compile the scss file into css (such as gulp-sass or grunt-sass). The simplest approach is to use the node-sass CLI - you simply run:

$ node-sass src/my-theme.scss dist/my-theme.css

Once Sass support is set up, instead of the pre-built css file, you need to import the provided scss file.
If using the mobiscroll npm package:

@import "~@mobiscroll/angularjs/dist/css/mobiscroll.scss"
Otherwise:
@import "./path/to/mobiscroll/css/mobiscroll.scss"

Override the Sass Color Variables

A convenient way to customize the colors af the Mobiscroll components is to override the Sass color variables.

Let's say your branding uses a nice red accent color, and you'd like that color to appear on the Mobiscroll components as well, while still using platform specific themes (e.g. ios on iOS devices, material on Android devices, and mobiscroll on desktop). You can override the accent color for every theme:

$mbsc-ios-accent: #e61d2a;
$mbsc-material-accent: #e61d2a;
$mbsc-mobiscroll-accent: #e61d2a;

@import "~@mobiscroll/angularjs/dist/css/mobiscroll.angularjs.scss"
It's important that you need to override the variables BEFORE the scss file import.

Of course you can customize more than just the accent, like background, text, primary, secondary colors, etc. Here's the complete list of the Sass variables being used:

iOS Theme

Variable name Default value Description
$mbsc-ios-accent
#007bff
Accent color
$mbsc-ios-background
#f7f7f7
Background color
$mbsc-ios-text
#000000
Text color
$mbsc-ios-dark-accent
#ff8400
Accent color for dark version
$mbsc-ios-dark-background
#000000
Background color for dark version
$mbsc-ios-dark-text
#ffffff
Text color for dark version
Variable name Default value Description
$mbsc-ios-primary
#3f97f6
Primary color
$mbsc-ios-secondary
#90979E
Secondary color
$mbsc-ios-success
#43BE5F
Success color
$mbsc-ios-danger
#f5504e
Danger color
$mbsc-ios-warning
#f8b042
Warning color
$mbsc-ios-info
#5BB7C5
Info color
$mbsc-ios-light
#ffffff
Light color
$mbsc-ios-dark
#47494A
Dark color

Material Theme

Variable name Default value Description
$mbsc-material-accent
#009688
Accent color
$mbsc-material-background
#eeeeee
Background color
$mbsc-material-text
#5b5b5b
Text color
$mbsc-material-dark-accent
#81ccc4
Accent color for dark version
$mbsc-material-dark-background
#303030
Background color for dark version
$mbsc-material-dark-text
#c2c2c2
Text color for dark version
Variable name Default value Description
$mbsc-material-primary
#3f97f6
Primary color
$mbsc-material-secondary
#90979E
Secondary color
$mbsc-material-success
#43BE5F
Success color
$mbsc-material-danger
#f5504e
Danger color
$mbsc-material-warning
#f8b042
Warning color
$mbsc-material-info
#5BB7C5
Info color
$mbsc-material-light
#ffffff
Light color
$mbsc-material-dark
#47494A
Dark color

Mobiscroll Theme

Variable name Default value Description
$mbsc-mobiscroll-accent
#4eccc4
Accent color
$mbsc-mobiscroll-background
#f7f7f7
Background color
$mbsc-mobiscroll-text
#454545
Text color
$mbsc-mobiscroll-dark-accent
#4fccc4
Accent color for dark version
$mbsc-mobiscroll-dark-background
#263238
Background color for dark version
$mbsc-mobiscroll-dark-text
#f7f7f7
Text color for dark version
Variable name Default value Description
$mbsc-mobiscroll-primary
#3f97f6
Primary color
$mbsc-mobiscroll-secondary
#90979E
Secondary color
$mbsc-mobiscroll-success
#43BE5F
Success color
$mbsc-mobiscroll-danger
#f5504e
Danger color
$mbsc-mobiscroll-warning
#f8b042
Warning color
$mbsc-mobiscroll-info
#5BB7C5
Info color
$mbsc-mobiscroll-light
#ffffff
Light color
$mbsc-mobiscroll-dark
#47494A
Dark color

Windows Theme

Variable name Default value Description
$mbsc-windows-accent
#0078d7
Accent color
$mbsc-windows-background
#f2f2f2
Background color
$mbsc-windows-text
#262626
Text color
$mbsc-windows-dark-accent
#0078d7
Accent color for dark version
$mbsc-windows-dark-background
#1a1a1a
Background color for dark version
$mbsc-windows-dark-text
#ffffff
Text color for dark version
Variable name Default value Description
$mbsc-windows-primary
#3f97f6
Primary color
$mbsc-windows-secondary
#90979E
Secondary color
$mbsc-windows-success
#43BE5F
Success color
$mbsc-windows-danger
#f5504e
Danger color
$mbsc-windows-warning
#f8b042
Warning color
$mbsc-windows-info
#5BB7C5
Info color
$mbsc-windows-light
#ffffff
Light color
$mbsc-windows-dark
#47494A
Dark color

Create Custom Themes Using Sass

If you'd like to use multiple color variations for the Mobiscroll components, the solution is to create one or more custom themes. A custom theme is a variation of one of the built in themes, referred as the base theme.

To create a custom theme using Sass, you can use the provided mbsc-custom-theme function, which can be called after the mobiscroll scss file has been imported:

@import "~@mobiscroll/angularjs/dist/css/mobiscroll.scss"

@include mbsc-custom-theme('mobiscroll-red', 'mobiscroll', ('background': #f7f7f7, 'text': #454545, 'accent': #e61d2a));
Function name Description
mbsc-custom-theme($theme-name, $base-theme-name, $colors) A function which creates the styling for a custom theme, with the specified colors

Parameters

  • $theme-name - String - Name of the custom theme.
  • $base-theme-name - String - Name of the base theme. Possible values: 'ios', 'material', 'mobiscroll', 'windows'.
  • $colors - Map - A key-value map containing the input colors. Possible keys: 'background', 'text', 'accent', 'button' (for iOS base theme only).

Before you can use the custom theme, you will also need to register it in your javascript / typescript code. This can be done after the mobiscroll resources has been loaded, but before using any of the components. Make sure to use the same name which was specified to the Sass function, and specify the same base theme as second parameter.

mobiscroll.customTheme('mobiscroll-red', 'mobiscroll');

You can now specify the newly created theme to any Mobiscroll component using the theme setting:

<input mobiscroll-calendar="{theme: 'mobiscroll-red'}" ng-model="myDate" />

Create Custom Themes Using the Theme Builder

If Sass support is not available in your project, or you prefer a visual theme editor, you can use our theme builder to create custom themes.

The theme builder is very easy to use, no coding is needed, you just choose the colors, and save the custom theme. Using our download builder you can select one or more custom themes to include in the package.

You can find more information on the theme builder features and usage here.