Skip to content

Commit 0d709c2

Browse files
Gerry-Fordeotikhomi
authored andcommitted
RHIDP-4567-1 - Provide the ability to load a custom Backstage theme from a dynamic plugin (redhat-developer#801)
* RHIDP-4567-1 - Provide the ability to load a custom Backstage theme from a dynamic plugin * RHIDP-4567-1 - Provide the ability to load a custom Backstage theme from a dynamic plugin
1 parent cda7afd commit 0d709c2

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

assemblies/assembly-customizing-the-appearance.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ include::modules/customizing-the-appearance/ref-customize-rhdh-default-rhdh.adoc
4242

4343
include::modules/customizing-the-appearance/ref-customize-rhdh-default-backstage.adoc[leveloffset=+1]
4444

45+
include::modules/customizing-the-appearance/proc-loading-custom-theme-using-dynamic-plugin.adoc[leveloffset=+1]
4546

4647
include::modules/customizing-the-appearance/ref-customize-rhdh-custom-components.adoc[leveloffset=+1]
4748

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 {product-short} theme from a dynamic plugin.
8+
9+
.Procedure
10+
11+
. Export a theme provider function in your dynamic plugin, for example:
12+
+
13+
.Sample `myTheme.ts` fragment
14+
[source,javascript]
15+
----
16+
import { lightTheme } from './lightTheme'; // some custom theme
17+
import { UnifiedThemeProvider } from '@backstage/theme';
18+
export const lightThemeProvider = ({ children }: { children: ReactNode }) => (
19+
<UnifiedThemeProvider theme={lightTheme} children={children} />
20+
);
21+
----
22+
+
23+
For more information about creating a custom theme, see link:https://backstage.io/docs/getting-started/app-custom-theme/#creating-a-custom-theme[Backstage documentation - Creating a Custom Theme].
24+
25+
. Configure {product-short} to load the theme in the UI by using the `themes` configuration field:
26+
+
27+
.`app-config-rhdh.yaml` fragment
28+
[source,yaml]
29+
----
30+
dynamicPlugins:
31+
frontend:
32+
example.my-custom-theme-plugin:
33+
themes:
34+
- id: light # <1>
35+
title: Light
36+
variant: light
37+
icon: someIconReference
38+
importName: lightThemeProvider
39+
----
40+
<1> Set your theme ID by specifying the desired value. Optionally, override the default {product-short} themes by using the following ID values: `light` to replace the default light theme, or `dark` to replace the default dark theme.
41+
42+
.Verification
43+
44+
* The theme is available in the {product-short} *Settings* page.

0 commit comments

Comments
 (0)