Getting Started
Theming
Customizing the default light and dark theme.
Theme Structure
Tremor's theming is managed in the theme
section of your tailwind.config.js
file. It includes a customizable light and dark mode, allowing you to tailor your design. Within the theme, you have the flexibility to define colors, border radii, shadows, and font sizes.
Note that by default the prefers-color-scheme
CSS media feature is used to toggle the dark mode. If
you want to use light mode only, add darkMode: "class"
to the tailwind.config.js
file.
Theme Tokens
To personalize the theme, modify the tokens accordingly. Each component has its own dedicated Theming section that provides further information about the theming tokens utilized in that particular component.
module.exports = { // ... theme: { transparent: "transparent", current: "currentColor", extend: { colors: { // light mode tremor: { brand: { faint: "#eff6ff", // blue-50 muted: "#bfdbfe", // blue-200 subtle: "#60a5fa", // blue-400 DEFAULT: "#3b82f6", // blue-500 emphasis: "#1d4ed8", // blue-700 inverted: "#ffffff", // white }, background: { muted: "#f9fafb", // gray-50 subtle: "#f3f4f6", // gray-100 DEFAULT: "#ffffff", // white emphasis: "#374151", // gray-700 }, border: { DEFAULT: "#e5e7eb", // gray-200 }, ring: { DEFAULT: "#e5e7eb", // gray-200 }, content: { subtle: "#9ca3af", // gray-400 DEFAULT: "#6b7280", // gray-500 emphasis: "#374151", // gray-700 strong: "#111827", // gray-900 inverted: "#ffffff", // white }, }, // dark mode "dark-tremor": { brand: { faint: "#0B1229", // custom muted: "#172554", // blue-950 subtle: "#1e40af", // blue-800 DEFAULT: "#3b82f6", // blue-500 emphasis: "#60a5fa", // blue-400 inverted: "#030712", // gray-950 }, background: { muted: "#131A2B", // custom subtle: "#1f2937", // gray-800 DEFAULT: "#111827", // gray-900 emphasis: "#d1d5db", // gray-300 }, border: { DEFAULT: "#1f2937", // gray-800 }, ring: { DEFAULT: "#1f2937", // gray-800 }, content: { subtle: "#4b5563", // gray-600 DEFAULT: "#6b7280", // gray-500 emphasis: "#e5e7eb", // gray-200 strong: "#f9fafb", // gray-50 inverted: "#000000", // black }, }, }, boxShadow: { // light "tremor-input": "0 1px 2px 0 rgb(0 0 0 / 0.05)", "tremor-card": "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)", "tremor-dropdown": "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)", // dark "dark-tremor-input": "0 1px 2px 0 rgb(0 0 0 / 0.05)", "dark-tremor-card": "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)", "dark-tremor-dropdown": "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)", }, borderRadius: { "tremor-small": "0.375rem", "tremor-default": "0.5rem", "tremor-full": "9999px", }, fontSize: { "tremor-label": ["0.75rem"], "tremor-default": ["0.875rem", { lineHeight: "1.25rem" }], "tremor-title": ["1.125rem", { lineHeight: "1.75rem" }], "tremor-metric": ["1.875rem", { lineHeight: "2.25rem" }], }, }, }, safelist: [ { pattern: /^(bg-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, variants: ["hover", "ui-selected"], }, { pattern: /^(text-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, variants: ["hover", "ui-selected"], }, { pattern: /^(border-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, variants: ["hover", "ui-selected"], }, { pattern: /^(ring-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, }, { pattern: /^(stroke-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, }, { pattern: /^(fill-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950))$/, }, ], plugins: [require("@headlessui/tailwindcss")], };
Notes on dark mode
Tremor uses by default your system preference (prefers-color-scheme CSS) to decide with mode is rendered. If you want to use white mode only, or manually switch to dark mode, add the following to your tailwind.config.js
file.
module.exports = { darkMode: "class", // ... };
Now, rather than relying on the prefers-color-scheme to determine the use of dark: classes, their application is contingent on the presence of the 'dark' class higher up in the HTML hierarchy. Lastly, if you would like to switch themes with a button, we highly recommend next-themes
Theming Example
Here's a KPI card with Tremor's standard light theme.
Revenue
45.598
$36.5% ($45.564)
78.484
We are tasked to make the light theme to fit our brand, which means, matching a particular shade of orange: #F97315. To bring our theme on brand, we look up the ProgressBar's documentation on Theming.
Element | Theme Token |
---|---|
Roundness borderRadiustremor-full | |
Background color colorstremor-brand-faint | |
Progress color colorstremor-brand-DEFAULT | |
Label color colorstremor-content-emphasis | |
Font size fontSizetremor-default |
To achieve our goal, we have to change two tokens. The background color token: tremor-brand-faint
and the progress color token: tremor-brand-DEFAULT
. In our tailwind.config.js
file, we look up the tokens in the colors section and make our changes.
module.exports = { // ... theme: { transparent: "transparent", current: "currentColor", extend: { colors: { // light mode tremor: { brand: { faint: "#F9BD9C", // <--- tremor-brand-faint, lighter shade of brand color muted: "#bfdbfe", subtle: "#60a5fa", DEFAULT: "#F99157", // <--- tremor-brand-DEFAULT, brand color emphasis: "#1d4ed8", inverted: "#ffffff", }, // ... }, }, }, }, };
Revenue
45.598
$36.5% ($45.564)
78.484
Need help? You can also ask the community on GitHub Discussions or Slack.