Configuration
This section explains how you can configure UI5 Web Components globally, and what configuration settings are available.
Configuration Settings
There are several configuration settings that affect all UI5 Web Components globally.
theme
The theme setting values above are the technical names of the supported themes:
- The
sap_horizonis known asMorning Horizonand it's the latest theme and default theme. - The
sap_horizon_darkis known asEvening Horizon. - The
sap_horizon_hcbis known asHigh Contrast Black. - The
sap_horizon_hcwis known asHigh Contrast White. - The
sap_fiori_3is known asQuartz Light. - The
sap_fiori_3_darkis known asQuartz Dark. - The
sap_fiori_3_hcbis known asQuartz High Contrast Black. - The
sap_fiori_3_hcwis known asQuartz High Contrast White.
The default theme (sap_horizon) is built in all UI5 Web Components. Thus, components are always themed.
Configuring another theme will additionally fetch and use that theme. Any theme is fetched just once.
To use additional themes (other than sap_horizon):
- Import the
Assets.jsmodule of each component library you're using, for example:
import "@ui5/webcomponents/dist/Assets.js";
import "@ui5/webcomponents-fiori/dist/Assets.js";
For more about assets, see the dedicated Assets section.
- Configure the additional theme either via the configuration script or module imports.
Example:
import { setTheme } from "@ui5/webcomponents-base/dist/config/Theme.js";
setTheme("sap_horizon_hcb");
- To reset the theme to the default one:
import { setTheme, getDefaultTheme } from "@ui5/webcomponents-base/dist/config/Theme.js";
setTheme(getDefaultTheme());
Note: Deprecated themes
The following themes are deprecated and no longer maintained - out of maintenance and left for compatibility only. The themes will be removed in the next major version.
We recommend using Horizon (sap_horizon) and Quartz (sap_fiori_3) theme families.
language
The language configuration setting does not have a default value (the default value is technically null).
This is how the language to use is determined:
- If a language is configured, it will be used.
- If no language is configured (the setting is
null), the user's browser language is checked, and if in the supported list, used. - If the user's browser language is not in the supported list, but is a variation of a supported language, this language will be used (e.g.
fr_**->fr) - The
enlanguage will be used.
The en language is built in all UI5 Web Components that have translatable texts. Thus, components are always translated.
Configuring another language will additionally fetch and use that language. Any language is fetched once.
To use additional languages (other than en):
- Import the
Assets.jsmodule of each component/icon library you're using (in general, each library that provides languages assets), for example:
import "@ui5/webcomponents/dist/Assets.js";
import "@ui5/webcomponents-fiori/dist/Assets.js";
import "@ui5/webcomponents-icons/dist/Assets.js";
For more about assets, see the dedicated Assets section.
- Configure the additional language either via the configuration script or module imports.
Example:
import { setLanguage } from "@ui5/webcomponents-base/dist/config/Language.js";
setLanguage("fr");
- To reset the langauge to the default one:
import { setLanguage, getDefaultLanguage } from "@ui5/webcomponents-base/dist/config/Language.js";
setLanguage(getDefaultLanguage());
animationMode
This setting only applies to components that run animations.
Animation modes allow to specify different animation scenarios or levels.
- When
full, all animations run unrestricted. - When
basic, more light-weight set of animations would run. - When
minimal, animations of fundamental functionalities are included. - When
none, all animations are completely suspended.
Note: Please, note that each component determines which animations would run for a specific mode.
calendarType
This setting determines the default calendar type for all date-related components such as ui5-date-picker, ui5-datetime-picker, etc.
You can always override the calendar type for each instance via component-specific properties. See the documentation of each component for details.
The Gregorian calendar type is built in all date-related UI5 Web Components.
Calendar types are opt-in features, see Using Features for details. Setting another calendar type via configuration or component properties requires that the respective calendar type be explicitly imported.
Example:
- Make sure you've bundled the required calendar type:
import "@ui5/webcomponents-localization/dist/features/calendar/Islamic.js";
- Configure this calendar:
<script data-ui5-config type="application/json">
{
"calendarType": "Islamic"
}
</script>
Now all date-related components will use the Islamic calendar type by default.
noConflict
By default, UI5 Web Components fire all custom events twice - once with the documented name (e.g. change), and once more with a ui5- prefix (e.g. ui5-change).
For example, when the ui5-switch is toggled, it fires a change event, but also a ui5-change event.
The noConflict configuration setting allows certain control over this behavior:
- When
false(default value), all custom events are fired with and without theui5-prefix. - When
true, all custom events are fired with theui5-prefix only. Hence thenoConflictsemantic in the name of the setting. This is handy, for example, if the name of an event, fired by a component, happens to collide with the name of an event provided by a third-party library. - When an object is supplied, just the specified events will be fired with the
ui5-prefix only. All other events will be fired normally - once with the prefix, and once without it. The format of this object is as follows:
{
"events": ["selection-change", "header-click"]
}
Note: Please, note that other keys may be added to this object in the future for the purpose of name conflict resolution.
In the above example, only the selection-change and header-click events will be fired with a prefix.
You can still use them by listening to ui5-selection-change and ui5-header-click, but the names selection-change and header-click will be
free for use by other UI components and libraries without name collision.
formatSettings
This setting allows to override locale-specific settings for date-related controls.
For example, to force the first day of week to Sunday, no matter the locale:
{
"formatSettings": {
"firstDayOfWeek": 0
}
}
Note: legacyDateCalendarCustomizing takes affect only if following features are imported:
@ui5/webcomponents-base/dist/features/LegacyDateFormats.js