Theming

Switch between dark and light mode

Overview

OnSphere currently supports two display mode :

  • dark-mode

  • light-mode

Note

The display mode is saved in the user preference.

Usage

You can specify which theme mode to use for front-end:

  • light: Uses light theme

  • dark: Uses dark theme (default)

You can also specify if the user can change the theme manually by using the icon in the dashboard header which is enabled by default. To disable this functionality, set modeIsLocked to true in stack.cfg file :

{
    "theme": {
        "mode": "dark",
        "modeIsLocked": false
    }
}

Theme overriding

Warning

Beta version

Features currently under evaluation may be modified in the next version without prior notice. If you are using these beta features, we welcome your feedback and experience. Your input is crucial to refining and improving these features before their official release. Please share your thoughts and experiences with us, and contribute to the evaluation process.

We support experimental theme overriding. This feature has no dispatcher validation and should be use with good understanding of underlying Material UI customization (see default theme viewer for all overridable parameters).

To extend current OnSphere theme, you can provide in the following content in stack.cfg file:

{
    "experimentalThemeOverride": {
        "all": {},
        "dark": {},
        "light": {}
    }
}

With the following example configuration, you will be able to achieve light and dark theme override:

../../_images/osp-color-override-both.png

Note

The complete can be checked out with git checkout origin/example-dashboard-experimental-theme-override .

{
    "moduleId": [
        "modules.keycloak.keycloak-1",
        "modules.web.web-1",
        "modules.configuration-dispatcher.main"
    ],
    "theme": {
        "mode": "dark",
        "modeIsLocked": false,
        "logoWithoutText": "",
        "logoWithText": "",
        "background": "",
        "favicon": "",
        "experimentalThemeOverride": {
            "all": {},
            "dark": {
                "palette": {
                    "background": {
                        "default": "#001aa4",
                        "paper": "#00116d"
                    },
                    "primary": {"main": "#7991FF"},
                    "secondary": {"main": "#002EFF"},
                    "text": {
                        "primary": "#7991FF"
                    }
                },
                "components": {
                    "MuiAppBar": {
                        "styleOverrides": {
                            "root": {
                                "backgroundColor": "#000B40",
                                "color": "#7991FF"
                            }
                        }
                    },
                    "MuiButton": {
                        "styleOverrides": {
                            "root": {
                                "color": "#7991FF"
                            }
                        }
                    },
                    "MuiSvgIcon": {
                        "styleOverrides": {
                            "root": {
                                "color": "#7991FF"
                            }
                        }
                    },
                    "MuiIcon": {
                        "styleOverrides": {
                            "root": {
                                "color": "#7991FF"
                            }
                        }
                    }
                }
            },
            "light": {
                "palette": {
                    "background": {
                        "default": "#ffedbe",
                        "paper": "#ffdc82"
                    },
                    "primary": {"main": "#966c00"},
                    "secondary": {"main": "#ffcc4a"},
                    "text": {
                        "primary": "#966c00"
                    }
                },
                "components": {
                    "MuiAppBar": {
                        "styleOverrides": {
                            "root": {
                                "backgroundColor": "#ffc700",
                                "color": "#966c00"
                            }
                        }
                    },
                    "MuiButton": {
                        "styleOverrides": {
                            "root": {
                                "color": "#966c00"
                            }
                        }
                    },
                    "MuiIcon": {
                        "styleOverrides": {
                            "root": {
                                "color": "#966c00"
                            }
                        }
                    },
                    "MuiSvgIcon": {
                        "styleOverrides": {
                            "root": {
                                "color": "#966c00"
                            }
                        }
                    }
                }
            }
        }
    }
}