---
title: Styles and libraries
project: UI Builder
version: 1.0
section: development
language: en
license: MIT
url: https://totaljs.es/docs/uibuilder/1-0/development/styles-and-assets/
updated: 2026-11-19T11:56:16.260Z
---

# Styles and libraries

> Style a component without affecting others, and load external scripts and styles.

## Styles

Put the CSS in `<style>` of `editor.html` and `render.html`. Start every rule with `.CLASS`:

```html
<style>
	.CLASS { padding: 15px 20px; border-radius: var(--radius); }
	.CLASS_title { font-weight: bold; }
	.CLASS.UI_touched.UI_invalid .CLASS_box { border-color: red; }
</style>
```

UI Builder replaces `CLASS` with the class name of the component, so the styles apply only to it. The same name is `cls`, the fourth argument of `exports.make`. Use it for your own class names:

```js
element.html('<div class="{0}_title"></div>'.format(cls));
```

The templates set CSS variables such as `--radius`, and the Total.js UI library gives the page its fonts and helper classes. The state of an instance adds classes such as `UI_invalid`; see [Values and data binding](../values-and-binding/).

## External libraries

List scripts and styles in `exports.import`. UI Builder loads each address once, before it builds the instances:

```js
exports.import = ['https://cdnjs.cloudflare.com/ajax/libs/apexcharts/3.36.3/apexcharts.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/apexcharts/3.36.3/apexcharts.min.css'];
```

The charts load ApexCharts this way, and **Map** loads Leaflet. Put `exports.import` in `render.html` too, because the published design reads only that file.

An address that starts with `/` is read from the server of UI Builder in the editor, and from the server of the page in a published design.

## Images and other files

Put the files in the folder of the component and use their full path, for example `/components/greeting/logo.png`. When the component is shared in the official repository, its paths of the form `/components/<id>/` are changed to the published address. See [Share a component](../share/).
