Skip to main content

Overview

All Tesouro 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 Tesouro components are immutable, you can customize other component properties, such as colors, fonts, borders, etc.

Theming mechanism

To customize the components, pass your custom theme object to the React SDK using the theme prop on the TesouroProvider. The following snippet shows an example theme object with all possible options using default values:
const defaultTheme = {
  borderRadius: 6,
  spacing: 8,

  colors: {
    primary: "#3737FF",
    secondary: "#707070",
    neutral: "#707070",
    info: "#3737FF",
    success: "#1FBCA0",
    warning: "#C78032",
    error: "#CC394B",
    background: "#FFFFFF",
    text: "#292929",
  },

  typography: {
    fontFamily:
      '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',
    fontSize: 16,
    h1: {
      fontSize: 48,
      fontWeight: 600,
      lineHeight: "68px",
    },
    h2: {
      fontSize: 34,
      fontWeight: 640,
      lineHeight: "40px",
    },
    h3: {
      fontSize: 24,
      fontWeight: 600,
      lineHeight: "32px",
    },
    subtitle1: {
      fontSize: 20,
      fontWeight: 600,
      lineHeight: "24px",
    },
    subtitle2: {
      fontSize: 18,
      fontWeight: 600,
      lineHeight: "24px",
    },
    body1: {
      fontSize: 16,
      fontWeight: 500,
      lineHeight: "24px",
    },
    body2: {
      fontSize: 14,
      fontWeight: 400,
      lineHeight: "20px",
    },
  },
};

function App() {
  return (
    <div className="App">
      <TesouroProvider tesouro={tesouro} theme={customTheme}>
        ...
      </TesouroProvider>
    </div>
  );
}

export default App;
Here is a description of all the possible options for the theming object, which allows you to customize the visual style of Tesouro UI components:

General

ParameterTypeDescription
borderRadiusnumberControls the border radius of UI components like buttons, cards, etc.
spacingnumberBase spacing unit used throughout the UI (in pixels).

colors

Color palette used throughout the UI.
ParameterTypeDescription
colors.primarystringMain brand color for primary buttons, links, and highlights.
colors.secondarystringSecondary color for less prominent UI elements.
colors.neutralstringNeutral tone for borders, dividers, and subtle UI elements.
colors.infostringInformational color (e.g. badges, info alerts).
colors.successstringSuccess state indicators and confirmations.
colors.warningstringWarnings and attention-grabbing notifications.
colors.errorstringError states and destructive action indicators.
colors.backgroundstringMain background color of the application.
colors.textstringDefault primary text color.

typography

Controls the font styling across the app.
ParameterTypeDescription
typography.fontFamilystringGlobal font family.
typography.fontSizenumberBase font size in pixels. Other text scales relative to this.

Typography Variants

Each variant is an object with the following fields: fontSize, fontWeight, lineHeight.
VariantDescription
typography.h1Main page heading
typography.h2Section heading
typography.h3Subsection heading
typography.subtitle1Primary subtitle
typography.subtitle2Secondary subtitle
typography.body1Primary body text
typography.body2Secondary body text (smaller)

Typography Variant Fields

FieldTypeDescription
fontSizenumberFont size in pixels.
fontWeightnumberFont weight (e.g., 400 = normal, 600 = bold).
lineHeightstringLine height in px.