mosaic
  • Overview
  • Integration
    • Next.js
    • Create React App
    • Webpack
  • Getting started
    • Extensions
    • Themes
  • Tutorials
    • Mosaic + React
    • Mosaic + Webpack
  • Install an extension
    • Install a local extension
    • Install with a package manager
    • Enable or disable an extension
  • Develop an extension
    • Anatomy of an extension
    • Namespaces
    • Runtime plugins
    • Build configuration plugins
  • CRA features
    • CRACO plugins
  • Next.js features
    • Styles
    • Pages
    • Common props
  • Architecture examples
    • Router
  • Themes
    • Parent theme system
    • File shadowing
  • Experimental
    • Module preferences
    • File provisioning
  • in-depth
    • How does it work?
Powered by GitBook
On this page
  • Create a parent theme
  • Use a parent theme

Was this helpful?

  1. Themes

Parent theme system

Mosaic introduces a concept of "themes"

Create a parent theme

Theme is a collection of components, which implements a presentation layer that is unique to your application. It should not contain any business logic. It should simply adopt extensions functionality to intended design of your application.

For application to be considered a theme, it must have a package.json field mosaic.type equal to theme

package.json
{
    "mosaic": {
        "type": "theme",
        "themeAlias": "Parent"
    }
}

Use a parent theme

Themes can stack on top of each other. A theme, which another theme is based on, is called a parent theme.

To specify a parent theme, set the package.json field mosaic.parentTheme equal to intended parent theme's package name.

If you are selecting a new parent theme, it is not enough to just set the value of mosaic.parentThemein package.json. The parent theme package should be listed among of your package's dependencies

The properly installed parent theme could look like this in package.json:

{
    "name": "@me/child-theme",
    "dependencies": {
        "@example/parent-theme": "1.0.1"
    },
    "mosaic": {
        "type": "theme",
        "parentTheme": "@example/parent-theme"
    }
}
PreviousRouterNextFile shadowing

Last updated 4 years ago

Was this helpful?

A theme can override files of a parent theme. Learn more about overriding a parent theme in the guide.

File overrides