Skip to content

Commit aeb78fb

Browse files
committed
RHIDP-4567 - Provide the ability to load a custom Backstage theme from a dynamic plugin
1 parent 01e7552 commit aeb78fb

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Module included in the following assemblies:
2+
// assembly-customize-rhdh-theme.adoc
3+
4+
[id="proc-loading-custom-theme-using-dynamic-plugin-_{context}"]
5+
= Loading a custom {product-short} theme by using a dynamic plugin
6+
7+
You can load a custom Backstage theme from a dynamic plugin.
8+
9+
.Procedure
10+
11+
. Export a theme provider function in the dynamic plugin, such as:
12+
+
13+
[source,javascript]
14+
----
15+
import { lightTheme } from './lightTheme'; // some custom theme
16+
import { UnifiedThemeProvider } from '@backstage/theme';
17+
export const lightThemeProvider = ({ children }: { children: ReactNode }) => (
18+
<UnifiedThemeProvider theme={lightTheme} children={children} />
19+
);
20+
----
21+
22+
. Configure {product-short} to load the them in the UI by using the new `themes` configuration field:
23+
+
24+
.Example `app-config-rhdh.yaml` file
25+
[source,yaml]
26+
----
27+
dynamicPlugins:
28+
frontend:
29+
example.my-custom-theme-plugin:
30+
themes:
31+
- id: light # <1>
32+
title: Light
33+
variant: light
34+
icon: someIconReference
35+
importName: lightThemeProvider
36+
----
37+
<1> Set your theme id. Optionally, override the default Developer Hub themes specifying following id value: `light` overrides the default light theme and `dark` overrides the default dark theme.
38+
39+
.Verification
40+
41+
* The theme is available in the "Settings" page.

0 commit comments

Comments
 (0)