A shared folder with AI prompts and code snippets
From workspace: HeroUI Chat
Team: Main
Total snippets: 11
11 snippets
ThemeColors
type ColorScale = { 50: string; 100: string; 200: string; 300: string; 400: string; 500: string; 600: string; 700: string; 800: string; 900: string; foreground: string; // contrast color DEFAULT: string; }; type BaseColors...
LayoutTheme
type BaseThemeUnit = { small?: string; medium?: string; large?: string; }; type FontThemeUnit = { small?: string; medium?: string; large?: string; tiny?: string; }; interface LayoutTheme { /** * The default font size applied...
ConfigThemes
type ConfigTheme = { extend?: "light" | "dark"; // base theme to extend layout?: LayoutTheme; // see LayoutTheme colors?: ThemeColors; // see ThemeColors }; type ConfigThemes = Record<string, ConfigTheme>;
The following table provides an overview of the various attributes you can use when working with themes in HeroUI:
.
HeroUI enables you to apply TailwindCSS styles based on the currently active theme. Below are examples of how to do this:
<!-- In dark theme, background will be dark and text will be light. In light theme, background will be light and text will be dark --> <div class="dark dark:bg-gray-800 dark:text-white bg-white text-black"> ... <div>Text color changes...
HeroUI supports nested themes, allowing you to apply different themes to different sections of your application:
<html class="dark"> ... <div class="light">...</div> <div class="purple-dark">...</div> </html>
These are the options that you can use to apply custom configurations to your themes.
module.exports = { plugins: [ heroui({ themes: { light: { layout: {}, colors: {} }, dark: { layout: {}, colors: {} }, ... // custom themes } }) ...
The heroui plugin provides a default structure. It is outlined as follows:
module.exports = { plugins: [ heroui({ prefix: "heroui", // prefix for themes variables addCommonColors: false, // override common colors (e.g. "blue", "green", "pink"). defaultTheme: "light", // default theme from the...
// main.tsx or main.jsx import React from "react"; import ReactDOM from "react-dom/client"; import {HeroUIProvider} from "@heroui/react"; import App from "./App"; import "./index.css"; ReactDOM.createRoot(document.getElementById("root")).render( ...
After adding the plugin to your tailwind.config.js file, you can utilize any of the default themes (light/dark) or a custom one. Here's how you can apply these themes in your main.jsx or main.tsx:
Go to the src directory and inside main.jsx or main.tsx, apply the following class names to the root element: light for the light theme. dark for the dark theme. text-foreground to set the text color. bg-background to set the background color.
The first step to using HeroUI's theming capability is adding the heroui plugin to your tailwind.config.js file. Below is an example of how to do this:
// tailwind.config.js const {heroui} = require("@heroui/react"); /** @type {import('tailwindcss').Config} */ module.exports = { content: [ // ... // make sure it's pointing to the ROOT node_module ...