BlueBase
  • 💧Introduction
  • Tutorial
    • 1. Getting Started
      • 1.1 Setup
      • 1.2 Add Plugins
      • 1.3 Create Custom Plugin
    • 2. Backend API
      • 2.1 Create Backend API
      • 2.2 Setup Apollo Client
      • 2.3 Generate Typescript Interfaces
    • 3. Create Screens
      • 3.1 Pending Tasks Screen
      • 3.2 Edit Task Screen
      • 3.3 Task Create Screen
      • 3.4 Tab Navigation
    • 4. CRUD Operations
      • 4.1 Creating Tasks
      • 4.2 Reading Tasks
      • 4.3 Updating Tasks
      • 4.4 Deleting Tasks
    • 5. Enhancements
      • 5.1 Internationalisation
      • 5.2 Theming
      • 5.3 Dynamic Images
      • 5.4 Settings & Configurations
      • User Management
  • Key Concepts
    • 🎡Lifecycle Events
    • â›Šī¸Main App Layout
    • 🔌Plugins
      • Plugin API
      • Register a Plugin
      • Making a Plugin Configurable
      • Developing an Analytics Plugin
      • Developing a Logger Plugin
      • Developing a Theme Plugin
    • 🚇Filters
    • 🎁Components
      • Components API
      • Registering a Component
      • Accessing Components
      • Higher Order Components
    • 🎨Themes
      • Consuming Selected Theme
      • Customise Themes
      • Customise Components
      • Theme Configs
      • Theme Structure
    • đŸŽ›ī¸Configs
  • API
    • 📈Analytics
    • 📔Logger
    • đŸ“ĻBlueBase Modules
    • Registry
  • Guides
    • âœ‚ī¸Code Splitting
    • đŸ‘ŊMigrating to V8
  • Components
    • ActivityIndicator
    • BlueBase
      • BlueBaseApp 📌
      • BlueBaseConsumer 📌
      • BlueBaseFilter 📌
      • ThemeConsumer 📌
    • Button
    • ComponentState 📌
    • EmptyState 📌
    • ErrorState 📌
    • Icons
      • Icon
      • DynamicIcon 📌
      • PluginIcon 📌
    • JsonSchema 📌
    • LoadingState 📌
    • Noop 📌
    • Observers
      • DataObserver 📌
      • ErrorObserver 📌
      • HoverObserver 📌
      • WaitObserver 📌
    • StatefulComponent 📌
    • Typography
    • View
Powered by GitBook
On this page
  • Override all themes
  • Specific variation, global usage
  • Specific variation, one time usage
  • Nesting Themes
  • Overriding Themes

Was this helpful?

Export as PDF
  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, no 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

BlueBase ships with two built-in themes: BlueBase Light & BlueBase Dark. You can extend any of the two to create you own theme.

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

export const MyCustomTheme = ('light')({
    name: 'MyCustomTheme',
    key: 'my-custom-theme',
    // ... theme props
});
import { BlueBaseApp } from '@bluebase/core';
import { MyCustomTheme } from './MyCustomTheme.ts';

export const App = () => (
    <BlueBaseApp themes={[MyCustomTheme]} />
);

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.

<View>
    <Text>Default light theme here</Text>
    <ThemeProvider theme="bluebase-dark">
        <View style={{ backgroundColor: theme.palette.background.default }}>
            <Text>Dark theme here</Text>
        </View>
    </ThemeProvider>
<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

Was this helpful?

🎨