SDK theming

Learn about components and wrappers on the Monite React SDK.

Overview

All Monite components use the default component styling by default. However, there may be scenarios where you want to customize this default styling to match the look and feel of your website’s design or brand identity.

While the fundamental layouts of these Monite components are immutable, you can customize other component properties, such as colors, fonts, borders, etc.

Material UI

Monite React SDK uses Material UI to deliver a robust and dynamic theming mechanism. This mechanism allows you to tailor the SDK’s appearance to suit your application’s unique style and branding.

Material UI theme

A theme in Material UI is an object that specifies the color of the components, darkness of the surfaces, level of shadow, appropriate opacity of ink elements, etc.

Theming mechanism

To customize components, pass your custom theme object to the React SDK using the theme prop on the MoniteProvider wrapper as shown:

1import { MoniteProvider } from "@monite/sdk-react";
2
3const customTheme = {
4 palette: {
5 ...
6 },
7 typography: {
8 ...
9 }
10});
11
12...
13
14return (
15 <MoniteProvider theme={customTheme}>
16 ...
17 </MoniteProvider>
18);

The React SDK has default values for all component properties. You can update component properties using Material UI’s theme variables within your theme object. This document only covers the most important theme variables. See the Material UI theming documentation for the complete list of variables.

  • .palette: the .palette object allows you to modify the color of the components to suit your brand design or identity. For more information, see Palette.
  • .typography: the .typography object handles text appearance for your components. This includes font sizes, weights, line heights, letter spacing, etc., for all components. For more information, see Typography.

Usage example

The following snippet shows an example theme object with detailed palette and typography objects:

1import { MoniteProvider } from "@monite/sdk-react";
2
3const customTheme = {
4 palette: {
5 mode: "light",
6 primary: {
7 main: "#42a5f5",
8 contrastText: "#fff",
9 },
10 background: {
11 paper: "#e3f2fd",
12 },
13 text: {
14 primary: "#000",
15 secondary: "#000",
16 },
17 success: {
18 main: "#1fb42b",
19 contrastText: "#fff"
20 },
21 },
22 typography: {
23 fontFamily: "Comic Sans MS, Comic Sans, cursive, monospace",
24 h2: {
25 fontSize: "26px",
26 fontWeight: "500",
27 },
28 h3: {
29 lineHeight: 1.13,
30 },
31 button: {
32 fontSize: "16px",
33 fontWeight: "300",
34 textTransform: "uppercase",
35 },
36 },
37};
38
39...
40
41function App() {
42 return (
43 <MoniteProvider theme={customTheme}>
44 ...
45 </MoniteProvider>
46 );
47}
48
49export default App

For the full list of variables and their configuration, see the Material UI documentation.