BlueRain
Github
  • 💧Introduction
  • Overview
    • 📲Quick Start
    • 🎛️Configuration with bluerain.js
    • 🎡Lifecycle Events
    • 🛣️Roadmap
  • Key Concepts
    • 🔌Plugins
      • Developing an Analytics Plugin
      • Developing a Logger Plugin
      • Developing a Theme Plugin
    • 🎣Hooks
    • 🎁Components
    • 📦BlueRain Modules
    • 🎛️Configs
    • 📈Analytics
    • 📔Logger
    • 🎨Themes
      • Installation
      • Consuming Selected Theme
      • Customise Themes
      • Customise Components
      • Theme Configs
      • Theme Structure
    • Registry
  • Guides
    • 🗿Icons
    • 🛂Migrating from V3
  • Components
    • Typography
    • Icons
      • Icon
      • DynamicIcon 📌
      • PluginIcon 📌
  • CLI
    • Expo
    • Web
    • Storybook (Web)
    • Storybook Native (Expo)
Powered by GitBook
On this page
  • Override all themes
  • Specific variation, global usage
  • Specific variation, one time usage
  • Nesting Themes
  • Overriding Themes
  1. Key Concepts
  2. Themes

Customise Themes

BlueBase supports different types of theme customisation requirements so that a developer can do a single usage customisation or globally override a theme.

Override all themes

There may be use cases where you may need to keep specific values same, n matter which theme is selected, i.e. primary colours, etc.

To do this, use the theme.overrides config. This change is global, and overrides all installed themes.

bluebase.ts
const bootOptions = {

	configs: {
		'theme.overrides': {
			components: {
				// component styles
			}
		}
	},
};

export default bootOptions;

Specific variation, global usage

Extend a theme

import { createTheme } from '@bluebase/core';

// ... TODO: current api may change

Specific variation, one time usage

Using the ThemeProvider overrides prop. This change is only for this tree.

  • Nesting themes

  • Overriding themes

Nesting Themes

It is possible to nest multiple themes in a single project. To theme a specific portion of your app, use the ThemeProvider component.

<BB.Components.View>
	<BB.Components.Text>Default light theme here</BB.Components.Text>
	<ThemeProvider theme="bluebase-dark">
		<BB.Components.View style={{ backgroundColor: theme.palette.background.default }}>
			<BB.Components.Text>Dark theme here</BB.Components.Text>
		</BB.Components.View>
	</ThemeProvider>
<BB.Components.View>

 In the example above, we pass the theme prop to the ThemeProvider component. This prop takes the key of the theme to use for children components. If this prop is not set, the globally selected theme is used.

Overriding Themes

The ThemeProvider component can also be used to override a theme for a one time usage.

<ThemeProvider theme="bluebase-dark" overrides={{ palette: { background: { default: 'red' } } }} >
	{/* All components here will now have a red background color */}
</ThemeProvider>

PreviousConsuming Selected ThemeNextCustomise Components

Last updated 6 years ago

🎨