cancel
Showing results for 
Search instead for 
Did you mean: 
GuyLevin
Sisense Team Member
Sisense Team Member

Adding Custom Fonts to BloX Widgets

 
GuyLevin_0-1682678684921.png

 

Introduction

BloX can import custom fonts to allow more design customization of the widget. A single or multiple custom fonts can be used in a widget.

This article explains the steps to add custom fonts to a BloX widget.
We will cover:

  • Example widget installation
  • Example widget setup explanation
  • Tip - How to find an extra font with Google Fonts

Example Widget Installation Instructions

  1. Extract the attached Zip file.
  2. Import dashboard – “BloX-Fontsexample.dash” to the Sisense environment.
    Note: this example doesn’t require data, so can be connected to any available data layer.
  3. Upload the CSS & font file (ttf) file to “/branding/BloX-stuff” on the environment. This path can be updated in the widget editor and CSS file.

The widget is available to use.

Example widget setup explanation

1. Font import

When using fonts with BloX, you can import them directly from the web using a URL, or copy the font files to the '/branding' folder of Sisense. Both methods can be used at the same time (as shown in the attached example).

Use font files stored within the Sisense branding folder (uploaded via file management UI).

Add a ‘@font-face’ rule to the CSS file.
Reference the font file to be used in the ‘src’ field.


GuyLevin_1-1682679000406.png


Use fonts hosted on the web

Create ‘@import’ command (see ‘Using Google fonts for custom fonts’) for the hosted font and add it to the ‘style’ section.
for example:

"style": “@import url('https://fonts.googleapis.com/css2?family=Amatic+SC:wght@400;700&display=swap'); ",

 

2. CSS file configuration

Configure the CSS classes to be used in the BloX widget (create all the classes needed for the widget).
For each class define the font to be used, using the ‘font-family’ CSS rule.
See ‘Using Google fonts for custom fonts’ for specific ‘font-family’ rule definition.

 

GuyLevin_2-1682679185327.png

 

3. BloX widget configuration

  • To set a font for all text within the BloX widget (default font) – add the imported font-family name to the 'fontFamily' parameter from the “Configuration” tab.

    GuyLevin_7-1682681252375.png
  • Add CSS file import to the main widget style section (make sure to keep any other ‘@import’ commands already in the section).
    "style": "@import url('/branding/blox-stuff/SetFonts.css');",​
  • To apply a specific custom font to a BloX element, add the CSS classes to the containers which will apply the fonts to that container.

GuyLevin_4-1682679478517.png

 

Tip - How to find an extra font with Google Fonts

Google Fonts are free and open source - https://fonts.google.com/
The website shows previews of the different font families and their varieties.



GuyLevin_5-1682679553345.png

 

Once a font is selected, the website provides the ‘@import’ command and the CSS rule to use the selected font family. It also allows the download of selected font files.

Get the ‘@import’ command and the CSS rule from the righthand toolbar under the ‘Use on the web section’. Make sure to change the embed option to ‘@import’.



GuyLevin_6-1682679621214.png

 

Conclusion

Using the example and instructions in this article helps using custom fonts in BloX widgets in an easy and straightforward way.

 

Rate this article:
Version history
Last update:
‎04-28-2023 08:53 AM
Updated by:
Contributors