Swap structural components#
Volto Light Theme (VLT) renders its structural components — the header, navigation, footer, and a few more — through the component registry from @plone/registry.
This lets a project replace any of them with its own implementation by registering a utility and flipping a setting, instead of shadowing the component through customizations.
Compared to shadowing, this approach is:
Explicit. The active component is named in configuration, not hidden in a file under
customizations.Composable. Several implementations can coexist under different names; a project selects which one renders.
Decoupled. A project binds to a stable name, not to an internal module path.
How it works#
VLT registers its own implementation of each structural component as a utility under the name vlt, with a type that names the role.
config.registerUtility({ name: 'vlt', type: 'navigation', method: Navigation });
A setting then selects which registered name renders for each role.
config.settings.vlt = {
components: {
breadcrumbs: 'vlt',
footer: 'vlt',
header: 'vlt',
languageSelector: 'vlt',
logo: 'vlt',
mobileNavigation: 'vlt',
navigation: 'vlt',
searchWidget: 'vlt',
tags: 'vlt',
},
};
These defaults reproduce the theme's standard behavior, so enabling nothing changes nothing.
Available components#
The following roles can be swapped. The value is the type you register against and the key you set under config.settings.vlt.components.
Setting |
Role |
|---|---|
|
The breadcrumbs trail |
|
The site footer |
|
The site header |
|
The language selector in the header |
|
The site logo |
|
The mobile (hamburger) navigation |
|
The main desktop navigation |
|
The header search widget |
|
The tags shown on content |
Fallback behavior#
If a setting names a component that is not registered, VLT falls back to its own vlt implementation rather than failing to render.
// 'typo' is not registered, so the theme's own navigation renders.
config.settings.vlt.components.navigation = 'typo';
This makes a misconfiguration degrade to the default instead of producing a blank or broken region.
Type safety#
The component settings are typed through the VLTSettings interface, which augments Volto's SettingsConfig.
The keys of config.settings.vlt.components are a fixed set, so a typo in a role name is a compile-time error rather than a silent no-op at render.