Learn how to configure and customize Frontile's theme system to match your application's design requirements.
Frontile provides two primary methods for configuring your theme:
The most straightforward way to customize Frontile is using CSS variables in your stylesheet. This approach leverages Tailwind v4's @theme directive for simple, performant customization.
Add customizations after importing the theme in your app/styles/app.css:
@import 'tailwindcss' source('../../');
@plugin "@frontile/theme/plugin/default";
@import "@frontile/theme";
@theme {
/* Customize design tokens */
--radius: 12px;
--border-width-default: 2px;
--size-icon-md: 20px;
--opacity-hover: .85;
}
Use CSS variables to customize:
--radius (one knob; the whole rounded-* scale is derived from it), plus --radius-pill and individual steps as escape hatches--border-width-thin, --border-width-heavy--size-icon-sm, --size-icon-md, --size-icon-lg--shadow-elevation-1, --shadow-elevation-2--opacity-hover, --opacity-disabledChoose CSS variables when you need to:
For more complex customization, especially colors, use JavaScript configuration. This method provides programmatic control and type safety.
Create frontile.js in your project root:
const { frontile } = require('@frontile/theme/plugin');
module.exports = frontile({
defaultTheme: 'light',
themes: {
light: {
colors: {
primary: {
subtle: '#eff6ff',
soft: '#93c5fd',
DEFAULT: '#3b82f6',
strong: '#1e40af'
}
}
},
dark: {
colors: {
primary: {
subtle: '#1e3a8a',
soft: '#3b82f6',
DEFAULT: '#60a5fa',
strong: '#dbeafe'
}
}
}
}
});
Then reference it in your CSS:
@import 'tailwindcss' source('../../');
@plugin "./../../frontile.js";
@import "@frontile/theme";
Use JavaScript configuration for:
Choose JavaScript configuration when you need to:
| Feature | CSS Variables | JavaScript Config |
|---|---|---|
| Border radius | ✅ Recommended | ❌ Not needed |
| Semantic colors | ❌ Use JS instead | ✅ Recommended |
| Icon sizes | ✅ Recommended | ❌ Not needed |
| Elevation shadows | ✅ Recommended | ❌ Not needed |
| Typography | ✅ Recommended | ❌ Not needed |
| Default theme | ❌ Not possible | ✅ Use JS |
| Runtime changes | ✅ Easy | ❌ Requires rebuild |
| Per-theme values | ✅ Simple | ⚠️ More complex |
For minor adjustments to existing tokens, use CSS variables:
@theme {
--radius: 6px; /* scales every rounded-* step down proportionally */
--opacity-hover: .9;
}
For primary color customization, use JavaScript:
module.exports = frontile({
themes: {
light: {
colors: {
primary: {
subtle: '#f0f9ff',
soft: '#7dd3fc',
DEFAULT: '#0ea5e9',
strong: '#0c4a6e'
}
}
}
}
});
Combine both methods for comprehensive customization:
// frontile.js - Customize colors
module.exports = frontile({
themes: {
light: {
colors: { /* custom colors */ }
}
}
});
/* app.css - Customize design tokens */
@theme {
--radius: 8px;
--size-icon-md: 18px;
}
Use CSS for theme-specific token values:
/* Light theme */
.light,
.dark .theme-inverse {
--opacity-hover: .85;
--shadow-elevation-2: 0px 4px 12px rgba(0, 0, 0, 0.1);
}
/* Dark theme */
.dark,
.light .theme-inverse {
--opacity-hover: .75;
--shadow-elevation-2: 0px 4px 12px rgba(0, 0, 0, 0.3);
}