Theming
The CLThemeProvider component is the foundation of Callaloo's theming system. It configures the visual appearance of your application and enables the use of custom themes. You should wrap your entire application with this component to ensure all Callaloo components receive proper styling.
Basic Usage
Default Theme
To use Callaloo with the default theme, wrap your application with the CLThemeProvider component:
<script setup lang="ts">
import CLThemeProvider from '@codeandfunction/callaloo/CLThemeProvider';
</script>
<template>
<div class="my-awesome-app">
<CLThemeProvider>
<!-- All of your components that contain any Callaloo components -->
</CLThemeProvider>
</div>
</template>Custom Theme
To use a custom theme configuration, pass a themeConfig prop to the CLThemeProvider:
<script setup lang="ts">
import CLThemeProvider from '@codeandfunction/callaloo/CLThemeProvider';
import { CLThemeConfig } from '@codeandfunction/callaloo';
const themeConfig: CLThemeConfig = {
colors: {
primary: {
'100': '#FF34FF',
// ... additional color shades
},
// ... other color palettes
},
darkMode: false,
fontFamily: 'Arial'
};
</script>
<template>
<div class="my-awesome-app">
<CLThemeProvider :theme-config="themeConfig">
<!-- All of your components that contain any Callaloo components -->
</CLThemeProvider>
</div>
</template>CSS Variables
Typography and sizing are controlled by CSS variables, so you can customize them from your own stylesheet. Callaloo declares its defaults in the callaloo.tokens cascade layer, so any unlayered CSS you write takes precedence regardless of load order.
:root {
--clll-base-size: 16px;
--clll-font-family: 'Inter', sans-serif;
--clll-font-family-heading: 'Playfair Display', serif;
--clll-font-family-label: 'Inter', sans-serif;
--clll-font-family-mono: 'JetBrains Mono', monospace;
--clll-letter-spacing: normal;
--clll-letter-spacing-heading: -0.02em;
--clll-letter-spacing-label: 0.04em;
--clll-letter-spacing-mono: 0;
}Variables
| Variable | Default | Where it can be set |
|---|---|---|
--clll-base-size | 1rem | :root, or the host element of a Shadow DOM |
--clll-font-family | System font stack | Any element |
--clll-font-family-heading | --clll-font-family | Any element |
--clll-font-family-label | --clll-font-family | Any element |
--clll-font-family-mono | monospace | Any element |
--clll-letter-spacing | Not set (inherited) | Any element |
--clll-letter-spacing-heading | --clll-letter-spacing | Any element |
--clll-letter-spacing-label | --clll-letter-spacing | Any element |
--clll-letter-spacing-mono | --clll-letter-spacing | Any element |
With no overrides, every component renders exactly as it did before these variables existed.
Font roles
Each component uses one of four font roles:
| Role | Components |
|---|---|
| Heading | CLHeading, including the titles of CLModal and CLBanner |
| Label | CLButton, CLPill, CLBadge |
| Mono | CLMaskedText (monospace mode), the color value in CLInput |
| Body | Every other component, including form labels |
Form labels use the body role. To give them the label font instead:
label[class*='clll-'] {
--clll-font-family: var(--clll-font-family-label);
--clll-letter-spacing: var(--clll-letter-spacing-label);
}Letter-spacing
The letter-spacing variables are not set by default, so text inherits the letter-spacing of the surrounding page, as it always has. Native form controls (CLInput, CLSelect, CLTextArea, CLTimePicker) keep the browser default of normal until --clll-letter-spacing is set.
Base size
Spacing, font sizes, border radii and control heights all derive from --clll-base-size. Its default of 1rem follows the font size of the document's <html> element. If your page changes the root font size (for example html { font-size: 18px }) and you don't want Callaloo to scale with it, set the base size explicitly:
:root {
--clll-base-size: 16px;
}--clll-base-size only takes effect on :root or on a Shadow DOM host element. Setting it on any other element has no effect, because the derived sizes are calculated where they are declared.
Shadow DOM
When Callaloo's styles are loaded inside a shadow root, the variables are declared on :host. Set your overrides on the host element itself, either from the page or from a :host rule inside the shadow root. Overrides on the page's :root do not reach inside the shadow root.
/* In the page */
my-widget {
--clll-base-size: 16px;
--clll-font-family: 'Inter', sans-serif;
}Using with Tailwind CSS
If you define fonts in Tailwind's @theme, point the Callaloo variables at them:
@import 'tailwindcss';
@theme {
--font-body: 'Chakra Petch', sans-serif;
--font-display: 'Silkscreen', monospace;
}
:root {
--clll-font-family: var(--font-body);
--clll-font-family-heading: var(--font-display);
--clll-font-family-label: var(--font-display);
}CSS variables and themeConfig.fontFamily
themeConfig.fontFamily still works. When it is set to anything other than the default, CLThemeProvider applies it as an inline style, which takes precedence over --clll-font-family in your stylesheet. Use one or the other. The CSS variables are recommended, because they also cover the heading, label and mono roles.
Component API
CLThemeProvider
Props
Optional:
theme-config: CLThemeConfig- A custom theme configuration that will be applied to all slotted content of theCLThemeProvidercomponent.
Required:
- None
Colors
The Callaloo design system uses a comprehensive color palette where each color has various shades represented from 100 to 900. The color system includes:
- Primary colors - Main brand colors
- Neutral colors - Grays and backgrounds
- Semantic colors - Success, warning, error states
- Interactive colors - Hover, focus, and active states
Each color shade serves different purposes:
- 100-300: Light tones for backgrounds and subtle elements
- 400-600: Medium tones for borders and secondary elements
- 700-900: Dark tones for text and primary elements
Default Color Palette
Here are the default color values included in Callaloo's theme:
Primary Colors
| Shade | Color | Hex Code | Usage |
|---|---|---|---|
| 0 | #ffffff | Pure white | |
| 100 | #def5ff | Light backgrounds | |
| 200 | #b6eeff | Subtle elements | |
| 300 | #75e3ff | Light accents | |
| 400 | #2cd6ff | Medium elements | |
| 500 | #00c8ff | Base primary | |
| 600 | #009cd4 | Interactive elements | |
| 700 | #007cab | Text and borders | |
| 800 | #00688d | Dark text | |
| 900 | #065674 | Darkest shade |
Neutral Colors
| Shade | Color | Hex Code | Usage |
|---|---|---|---|
| 0 | #ffffff | Pure white | |
| 100 | #F7F7F7 | Light backgrounds | |
| 200 | #F2F2F2 | Subtle backgrounds | |
| 300 | #EBEBEB | Light borders | |
| 400 | #E6E6E6 | Medium borders | |
| 500 | #DEDEDE | Base neutral | |
| 600 | #B3B3B3 | Disabled elements | |
| 700 | #858585 | Secondary text | |
| 800 | #595959 | Primary text | |
| 900 | #2B2B2B | Darkest text |
Semantic Colors
Success (Green)
| Shade | Color | Hex Code | Usage |
|---|---|---|---|
| 0 | #ffffff | Pure white | |
| 100 | #9effb2 | Light success backgrounds | |
| 200 | #69f68d | Success highlights | |
| 300 | #56e57e | Light success accents | |
| 400 | #41d56e | Medium success elements | |
| 500 | #22c55d | Base success | |
| 600 | #00a147 | Success interactions | |
| 700 | #007230 | Success text | |
| 800 | #00441a | Dark success | |
| 900 | #001f08 | Darkest success |
Danger (Red)
| Shade | Color | Hex Code | Usage |
|---|---|---|---|
| 0 | #ffffff | Pure white | |
| 100 | #ffd3ce | Light error backgrounds | |
| 200 | #ffb2ac | Error highlights | |
| 300 | #ff8e88 | Light error accents | |
| 400 | #fe6561 | Medium error elements | |
| 500 | #e74c4c | Base danger | |
| 600 | #d20e27 | Error interactions | |
| 700 | #9b0018 | Error text | |
| 800 | #63000c | Dark error | |
| 900 | #360003 | Darkest error |
Warning (Yellow)
| Shade | Color | Hex Code | Usage |
|---|---|---|---|
| 0 | #ffffff | Pure white | |
| 100 | #ffeaba | Light warning backgrounds | |
| 200 | #ffdf95 | Warning highlights | |
| 300 | #ffd36a | Light warning accents | |
| 400 | #fdc836 | Medium warning elements | |
| 500 | #f5be1a | Base warning | |
| 600 | #c79800 | Warning interactions | |
| 700 | #8a6900 | Warning text | |
| 800 | #4f3b00 | Dark warning | |
| 900 | #211700 | Darkest warning |
Info (Blue)
| Shade | Color | Hex Code | Usage |
|---|---|---|---|
| 0 | #ffffff | Pure white | |
| 100 | #cfe2ff | Light info backgrounds | |
| 200 | #afceff | Info highlights | |
| 300 | #8eb9ff | Light info accents | |
| 400 | #6ca4ff | Medium info elements | |
| 500 | #4e8ff8 | Base info | |
| 600 | #2470e7 | Info interactions | |
| 700 | #004cb5 | Info text | |
| 800 | #002e73 | Dark info | |
| 900 | #00153e | Darkest info |
Secondary (Gray-Blue)
| Shade | Color | Hex Code | Usage |
|---|---|---|---|
| 0 | #ffffff | Pure white | |
| 100 | #DEE2E8 | Light secondary backgrounds | |
| 200 | #BFC7D4 | Secondary highlights | |
| 300 | #9EAABD | Light secondary accents | |
| 400 | #8090A8 | Medium secondary elements | |
| 500 | #61738E | Base secondary | |
| 600 | #4F5D73 | Secondary interactions | |
| 700 | #3A4555 | Secondary text | |
| 800 | #272F3A | Dark secondary | |
| 900 | #13161B | Darkest secondary |
Theme Configuration
The CLThemeConfig interface allows you to customize:
- Colors: Complete color palette with shades 100-900
- Dark Mode: Enable/disable dark mode styling
- Font Family: Set the body font family for your application. For heading, label and mono fonts, letter-spacing and the base size, use the CSS variables
Best Practices
Application Root: Always place
CLThemeProviderat the root of your application to ensure consistent theming across all components.Color Consistency: When creating custom themes, maintain the 100-900 shade structure for consistent component behavior.
Theme Switching: You can dynamically change themes by updating the
theme-configprop reactively.