API

Viewer HTML Element Styling

While the Babylon Viewer provides default UI for most capabilities of the Viewer, all of this UI can be customized by:

  • Styling via CSS variables
  • Styling via custom element CSS shadow parts
  • Full control of the UI with slots

CSS Variables

The following CSS variables can be used to change basic styling of the default UI:

VariableDescription
--ui-foreground-color
The default color for the foreground of all UI elements.
--ui-background-hue
The default hue for the background of all UI elements.
--ui-background-saturation
The default saturation for the background of all UI elements.
--ui-background-lightness
The default lightness for the background of all UI elements.
--ui-background-opacity
The default opacity for the background of all UI elements.
--ui-background-color
The default color for the background of all UI elements (by default, derived from the background hue, saturation, lightness, and opacity).
--ui-background-color-hover
The default color for the background of all UI elements when hovered (by default, derived from the background hue, saturation, lightness, and opacity).

Parts

The following CSS shadow parts can be used for more complex styling changes of the default UI:

PartDescription
progress-bar
The loading progress bar that is displayed near the top of the custom element by default.
tool-bar
The toolbar that has controls for animation, material variants, and hotspots and that is displayed near the bottom of the custom element by default.

Slots

The following slots can be used to completely replace the default UI:

SlotDescription
progress-bar
The default progress bar.
tool-bar
The default toolbar.

When replacing the default UI, you can use the properties, functions, and events of the HTML3DElement (<babylon-viewer>) to bind the UI to the custom element state.

Example of replacing the default loading progress bar:

Example of replacing the default tool bar:

Further reading

Viewer Default UI
Default UI provided by the HTML3DElement (<babylon-viewer>).
Viewer Default UI
Viewer HotSpots
HotSpots and annotations in the Viewer.
Viewer HotSpots