Skip to main content

Theming

react-mosaic ships a neutral default theme plus a Blueprint-integrated one. Both are opt-in: the library renders nothing visible until you pull in a stylesheet, and which stylesheet you pull in decides the look.

The required stylesheet​

You must import the library CSS somewhere in your app:

import 'react-mosaic-component/react-mosaic-component.css';

This bundles the layout rules (split bars, drop targets, drag preview) and the default theme in one file. Without it, panels render but have no dividers, no hover states, and no drop indicators.

Applying a theme: className on <Mosaic>​

The className prop on Mosaic is how you pick a theme. The library recognises two built-in values:

  • 'mosaic-blueprint-theme' — matches Blueprint's default (light) palette.
  • 'mosaic-blueprint-theme bp5-dark' — Blueprint dark mode. (Combine with blueprintNamespace="bp5" so internal icons render via Blueprint's icon font.)
<Mosaic<string>
className="mosaic-blueprint-theme bp5-dark"
blueprintNamespace="bp5"
renderTile={/* ... */}
initialValue={/* ... */}
/>

If you're not using Blueprint at all, leave className empty — the default neutral theme is always on.

Writing your own theme​

Every visual rule in the library is namespaced under .mosaic-*. To theme your own panels, add a class to Mosaic and scope overrides to it:

.my-theme.mosaic {
background: #0b1220;
}

.my-theme .mosaic-window {
background: #111a2c;
border: 1px solid #1f2a44;
border-radius: 6px;
}

.my-theme .mosaic-window-title {
background: linear-gradient(90deg, #1a2236, #111a2c);
color: #cbd5e0;
}

.my-theme .mosaic-split:hover {
background: #4c90f0;
}
<Mosaic className="my-theme" renderTile={/* ... */} />

You don't need to restyle everything — the default theme is the base, and your class overrides only what you specify.

The class names that matter​

When writing a theme, these are the selectors you'll most often target:

SelectorWhat it is
.mosaicRoot container
.mosaic-windowIndividual panel
.mosaic-window-titleTitle bar area
.mosaic-window-bodyPanel content area
.mosaic-window-toolbarWhole title bar (title + controls)
.mosaic-window-controlsRight-hand button cluster
.mosaic-splitDraggable divider between siblings
.mosaic-split.-row / .-columnDirection-specific divider
.mosaic-split-lineThe visible line inside a divider
.mosaic-drop-targetHover target shown during drag
.mosaic-tab-barTab strip of a tab group
.mosaic-tab-buttonSingle tab header
.mosaic-tab-button.-activeThe currently-selected tab header
.mosaic-zero-stateEmpty-state placeholder

Class names are mosaic-<element>, and states are separate -modifier classes (-row, -active, -dragging). If you can't find a class, inspect a running demo in DevTools; the names are stable.

Styling the split bar​

A row split has a vertical divider and a column split has a horizontal one. Style the divider itself for hover effects. Note there is no space before :hover:

.my-theme .mosaic-split.-row:hover {
background: #4c90f0;
}

With the Blueprint theme, the theme already sets the hover background, so match its specificity to override it, or style the inner line instead:

.mosaic.mosaic-blueprint-theme .mosaic-split.-row:hover {
background: #4c90f0;
}

/* or keep the background and recolor the line */
.mosaic.mosaic-blueprint-theme .mosaic-split:hover .mosaic-split-line {
box-shadow: 0 0 0 2px #4c90f0;
}

Live example​

Flip between themes in the demo app — the theme selector in the toolbar toggles className on a live <Mosaic> instance. That's the whole integration: one string.