Skip to main content Skip to complementary content

Styling your visualizations

When creating visualizations for Qlik Sense, the following basic types of Cascading Style Sheets (css) are supported:

  • Inline: code is written into the tag and is only having an effect to the tag in which they are applied to.
  • External: code is created in a separate document and are attached to the visualization.
It is good programming practice to keep your styling in a separate css file. Separating the content from the design makes it easier to maintain your visualizations.

Qlik Sense set the css class qv-object-[extension name] on your visualizations and your css rules should be prefixed with that.

Example: Prefix css rules

.qv-object-com-qliktech-horizlist .qv-object-content { overflow: auto; } .qv-object-com-qliktech-horizlist ul { list-style: none; } .qv-object-com-qliktech-horizlist li.data { display: inline-block; margin: 3px; padding: 4px; border-top: 1px solid #ddd; border-left: 1px solid #ddd; border-bottom: 1px solid #111; border-right: 1px solid #111; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

Then you load your css file with requirejs and add its content to the html file.

Example: Load css file

define(["jquery", "text!./horizlist.css"], function($, cssContent) {'use strict'; $("<style>").html(cssContent).appendTo("head");

Reusing css files for multiple visualizations

You can reuse your css file if you are creating multiple visualizations that should have the same styling applied. Then store the css in a separate folder and link to it from the visualizations for which it should apply.

Short hand styling

To improve performance and make the css file load faster, it is good programming practice to code your style sheet using short hand.

Example: Styling short hand

Instead of this:

#potatoe { margin-left: 3px; margin-right: 4px; margin-top: 5px; }

You should do this:

#potatoe { margin: 5px 4px 0px 3px; // top, right, bottom and left values respectively. }

Compatibility

To save time, write the css for Firefox because it is more probable that it will work well in other browsers.

Examples

The below css examples are included in the Simple table code example, included in your Qlik Sense installation.

Example: Loading css content and adding it to the html page

define(["jquery", "text!./simpletable.css"], function($, cssContent) { 'use strict'; $("<style>").html(cssContent).appendTo("head");

Example: simpletable.css

.qv-object-com-qliktech-simpletable div.qv-object-content-container { overflow: auto; } .qv-object-com-qliktech-simpletable td, th { border-top: 0px solid #fff; border-bottom: 1px solid #ddd; border-right: 1px solid #ddd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; cursor: default; font-size: 12px; } .qv-object-com-qliktech-simpletable td.numeric { text-align: right; } .qv-object-com-qliktech-simpletable button { width: 100%; }

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!