Skip to main content
RapidDev - Software Development Agency
lovable-integrationsEdge Function Integration

How to Integrate Lovable with Tailwind CSS

Tailwind CSS is Lovable's default styling system — every app Lovable generates uses it automatically. To customize your theme, you edit tailwind.config.ts directly via Lovable's chat. You can extend the default color palette, add custom fonts, configure spacing scales, and add Tailwind plugins like tailwindcss-animate. Prompt Lovable with exact design tokens and it writes the config changes for you.

What you'll learn

  • How Tailwind CSS is pre-configured in every Lovable project and what files control it
  • How to extend the default Tailwind palette with custom brand colors via tailwind.config.ts
  • How to add custom fonts, spacing scales, and border radii to the Tailwind theme
  • How to install and configure Tailwind plugins like tailwindcss-animate inside Lovable
  • How to write Lovable chat prompts that reliably produce correct Tailwind customizations
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate16 min read15 minutesDesignMarch 2026RapidDev Engineering Team
TL;DR

Tailwind CSS is Lovable's default styling system — every app Lovable generates uses it automatically. To customize your theme, you edit tailwind.config.ts directly via Lovable's chat. You can extend the default color palette, add custom fonts, configure spacing scales, and add Tailwind plugins like tailwindcss-animate. Prompt Lovable with exact design tokens and it writes the config changes for you.

Customizing Tailwind CSS in Lovable: Theme Config, Plugins, and Design Tokens

Every app Lovable generates comes with Tailwind CSS pre-installed and pre-configured. You did not set it up, and you cannot turn it off — Tailwind is the entire styling layer. The default configuration is a solid starting point, but real products need brand colors, specific font families, and consistent spacing that matches a design system. That customization lives in a single file: tailwind.config.ts at the root of every Lovable project.

Lovable's AI has strong knowledge of tailwind.config.ts. You can describe your brand palette in plain language — 'our primary color is #2563EB, secondary is #7C3AED, and we use Inter for all text' — and Lovable will write the correct configuration, update the CSS variables in index.css, and apply the new classes throughout the existing components. This is significantly faster than hand-editing the config file and hunting down every className that needs updating.

The relationship between tailwind.config.ts and shadcn/ui is important to understand. Lovable uses shadcn/ui components for its UI primitives (buttons, cards, dialogs, inputs), and shadcn/ui reads its color values from CSS custom properties defined in index.css — not directly from tailwind.config.ts. When you customize Tailwind colors, you often need to update both files. Lovable handles this automatically when you describe changes in chat, but knowing the two-file system helps you write more precise prompts and troubleshoot cases where a component's color did not update as expected.

Integration method

Edge Function Integration

Tailwind CSS is already installed and active in every Lovable project — there is nothing to connect. The integration work is customization: editing tailwind.config.ts to extend the default theme with your brand tokens, adding plugins, and prompting Lovable to apply custom classes throughout the app. Lovable's AI understands tailwind.config.ts deeply and can make precise configuration edits from natural language instructions.

Prerequisites

  • A Lovable account with an existing project (free or paid)
  • Basic familiarity with Lovable's chat interface for making code changes
  • Your brand color hex codes, font names, or design tokens ready to reference in prompts
  • Optional: access to your tailwind.config.ts file via Lovable's Dev Mode (paid) or GitHub to review changes

Step-by-step guide

1

Understand the Tailwind file structure Lovable generates

Before customizing anything, it helps to know what files control Tailwind in your Lovable project. Open your project and click the Code panel button (the angle-bracket icon in the top toolbar). If you are on a paid plan with Dev Mode enabled, you can browse the file tree directly. The two key files are tailwind.config.ts in the project root and src/index.css. The tailwind.config.ts file defines your theme — colors, fonts, spacing, border radii, animations, and plugins. The src/index.css file defines CSS custom properties (--background, --primary, --foreground, and others) that shadcn/ui components read via Tailwind's utility classes. Changes to tailwind.config.ts add new utilities; changes to index.css adjust the default values that shadcn components actually render. You do not need Dev Mode to make changes — you can ask Lovable in chat to show you the current contents of tailwind.config.ts, and it will display the file so you can see what is already configured before asking for modifications. This prevents accidentally overwriting customizations you have already made. If you have connected your project to GitHub, you can also view tailwind.config.ts directly in the repository without needing Dev Mode. Either way, seeing the current state before requesting changes gives Lovable's AI the context it needs to make precise, additive edits rather than rewriting the entire config from scratch.

Lovable Prompt

Show me the current contents of tailwind.config.ts and src/index.css so I can see how Tailwind is configured in this project.

Paste this in Lovable chat

Pro tip: If you have connected your project to GitHub, you can view tailwind.config.ts directly in the GitHub repository without needing a paid Dev Mode plan.

Expected result: Lovable displays the current tailwind.config.ts and src/index.css contents in chat. You can see the existing theme configuration, color definitions, and any plugins already registered.

2

Extend the Tailwind theme with custom brand colors

Tailwind ships with a large default color palette (slate, gray, zinc, blue, violet, and others), but production apps need specific brand colors that match a design system or style guide. You extend — rather than replace — the default palette by adding values inside the theme.extend block in tailwind.config.ts. This preserves all default Tailwind colors while adding your custom ones as new utility classes. For example, adding a 'brand' color key with shades 50 through 950 creates utilities like bg-brand-500, text-brand-700, and border-brand-200 that you can use anywhere in your app. When you also want shadcn/ui components (buttons, badges, alerts) to use your brand colors, you need to update the corresponding CSS custom properties in index.css. The --primary variable controls the default button background, --primary-foreground controls button text, and --ring controls focus rings. Lovable handles both files simultaneously when you describe the change clearly. The most reliable way to prompt this is to give exact hex codes and specify which CSS custom property each maps to if you know it, or simply describe the visual result you want and let Lovable infer the mapping. For hex-to-HSL conversion (required for the index.css variables), just ask Lovable to do the conversion as part of the same prompt.

Lovable Prompt

Add my brand colors to tailwind.config.ts under theme.extend.colors: primary is #2563EB with shades from 50 to 950, and secondary is #7C3AED with the same shade range. Also update the --primary and --secondary CSS variables in index.css so the default shadcn button and badge components use these colors.

Paste this in Lovable chat

tailwind.config.ts
1import type { Config } from 'tailwindcss';
2
3const config: Config = {
4 darkMode: ['class'],
5 content: [
6 './pages/**/*.{ts,tsx}',
7 './components/**/*.{ts,tsx}',
8 './app/**/*.{ts,tsx}',
9 './src/**/*.{ts,tsx}',
10 ],
11 theme: {
12 extend: {
13 colors: {
14 // Brand palette — extend, don't replace default Tailwind colors
15 brand: {
16 50: '#eff6ff',
17 100: '#dbeafe',
18 200: '#bfdbfe',
19 300: '#93c5fd',
20 400: '#60a5fa',
21 500: '#3b82f6',
22 600: '#2563eb',
23 700: '#1d4ed8',
24 800: '#1e40af',
25 900: '#1e3a8a',
26 950: '#172554',
27 },
28 secondary: {
29 50: '#f5f3ff',
30 100: '#ede9fe',
31 200: '#ddd6fe',
32 300: '#c4b5fd',
33 400: '#a78bfa',
34 500: '#8b5cf6',
35 600: '#7c3aed',
36 700: '#6d28d9',
37 800: '#5b21b6',
38 900: '#4c1d95',
39 950: '#2e1065',
40 },
41 },
42 },
43 },
44 plugins: [],
45};
46
47export default config;

Pro tip: Use theme.extend.colors to ADD colors alongside Tailwind defaults. Using theme.colors without extend REPLACES the entire default palette — you lose blue, red, gray, and all other built-in colors.

Expected result: tailwind.config.ts now includes your brand color palette under theme.extend.colors. You can use classes like bg-brand-600, text-secondary-500, and border-brand-200 anywhere in the app. shadcn buttons and interactive elements reflect the new primary color.

3

Configure custom typography with a Google Font

Tailwind's default font stack falls back to the operating system's sans-serif font, which varies across Windows, macOS, and mobile devices. For consistent brand typography, you load a specific web font and register it in tailwind.config.ts under theme.extend.fontFamily. The two-part process involves importing the font (via a link tag in index.html or a CSS @import in index.css) and then referencing that font family name in the Tailwind config. Once registered, you can use classes like font-sans on any element, or set a font as the default for the entire document by applying the font class to the body element in index.css. Google Fonts is the most common source — Lovable can add the correct link tag to index.html and configure the Tailwind fontFamily extension in one prompt. If you use Inter (the most popular choice for SaaS apps), note that many browsers and operating systems ship Inter natively, so the font may render immediately without a network request in many cases. For premium fonts from Adobe Fonts or a licensed type foundry, you provide the CSS @font-face declaration and Lovable wires it into the config the same way. The fontFamily config accepts an array of font names as a fallback chain — always include system-ui and sans-serif as final fallbacks so text remains readable if the web font fails to load.

Lovable Prompt

Add Inter from Google Fonts to this project. Import the 400, 500, and 600 weights. Configure it as the default sans-serif font in tailwind.config.ts under theme.extend.fontFamily as 'sans'. Apply it to the body element in index.css so all text defaults to Inter.

Paste this in Lovable chat

tailwind.config.ts (fontFamily snippet)
1// In tailwind.config.ts — fontFamily extension
2theme: {
3 extend: {
4 fontFamily: {
5 sans: ['Inter', 'ui-sans-serif', 'system-ui', 'sans-serif'],
6 // Optional: separate display and mono stacks
7 display: ['Cal Sans', 'Inter', 'ui-sans-serif', 'system-ui'],
8 mono: ['JetBrains Mono', 'ui-monospace', 'monospace'],
9 },
10 },
11},

Pro tip: After adding a font, check the Network tab in your browser DevTools to confirm the font file is loading. If you see a font flash on page load, add display=swap to the Google Fonts URL query string: ?display=swap.

Expected result: Your app loads Inter from Google Fonts. All text elements render in Inter at the configured weights. The font-sans class and body default now resolve to Inter instead of the system font stack.

4

Add Tailwind plugins for animations and utility extensions

Tailwind plugins extend the framework with pre-built utility classes beyond the defaults. The most important plugin for Lovable projects is tailwindcss-animate — it provides the keyframe animations that shadcn/ui components depend on for dialog open/close transitions, dropdown fades, tooltip appears, and accordion expansion. If your shadcn dialogs or dropdowns render without animation, or if you see build warnings about missing animation utilities, this plugin is either not installed or not registered in tailwind.config.ts. Another commonly useful plugin is @tailwindcss/typography, which adds the prose utility for rendering rich text content (markdown, blog posts, legal pages, documentation) with properly spaced headings, paragraphs, and code blocks. To add a plugin, you need both the package in package.json and an entry in the plugins array of tailwind.config.ts. Lovable handles both steps when you ask it in chat — it updates package.json, installs the dependency, and adds the plugin registration. You can verify the plugin is active by using one of its utility classes (like animate-in or prose) in a component and confirming no build error or unknown class warning appears. For Lovable projects that use shadcn/ui (which is all of them), tailwindcss-animate should be treated as a required plugin rather than an optional one. Check the current tailwind.config.ts before asking Lovable to add it, since it is already present in most Lovable projects.

Lovable Prompt

Make sure tailwindcss-animate is installed as a dependency and registered in the plugins array of tailwind.config.ts. Also add @tailwindcss/typography so I can use the prose class for rendering rich text content.

Paste this in Lovable chat

tailwind.config.ts
1import type { Config } from 'tailwindcss';
2import animate from 'tailwindcss-animate';
3import typography from '@tailwindcss/typography';
4
5const config: Config = {
6 darkMode: ['class'],
7 content: [
8 './pages/**/*.{ts,tsx}',
9 './components/**/*.{ts,tsx}',
10 './app/**/*.{ts,tsx}',
11 './src/**/*.{ts,tsx}',
12 ],
13 theme: {
14 extend: {},
15 },
16 plugins: [
17 animate,
18 typography,
19 ],
20};
21
22export default config;

Pro tip: tailwindcss-animate is already included in most Lovable projects by default. Check the current config before asking Lovable to add it to avoid duplicate plugin entries.

Expected result: Both plugins appear in the tailwind.config.ts plugins array. shadcn dialogs, dropdowns, and tooltips animate correctly on open and close. You can apply the prose class to any div containing HTML content and it renders with proper typographic spacing and hierarchy.

5

Use the @file syntax to make precise, scoped config edits

For complex Tailwind config changes, Lovable's @file syntax helps the AI focus on exactly the file you want to modify without accidentally altering unrelated components or other sections of the config. When you type @tailwind.config.ts in Lovable's chat input, the AI anchors its response to that specific file's current content, which is especially useful for additive changes — you want to add a new color to an existing palette, or register a new plugin alongside one that is already configured. You can combine @file references in one prompt: @tailwind.config.ts for the config and @src/index.css for the CSS variables, letting Lovable reason about both files simultaneously when making changes that touch both, such as adding a new color that needs both a Tailwind extension token and a CSS custom property for shadcn compatibility. To use this effectively, start your prompt with the @file reference and describe the change specifically: '@tailwind.config.ts — add a rose color palette under theme.extend.colors for my error state design, and update @src/index.css to set --destructive to rose-600 so shadcn alert components use it.' This focused approach produces more reliable edits on complex configuration files with many existing settings. For ambitious design system implementations involving many color tokens, typography scales, responsive breakpoints, and plugin configurations, RapidDev's team can help design the full tailwind.config.ts architecture and ensure consistency between the config, index.css, and component-level class usage.

Lovable Prompt

@tailwind.config.ts add a custom spacing scale under theme.extend.spacing with values: 18 (4.5rem), 22 (5.5rem), 26 (6.5rem), and 30 (7.5rem). These will be used for section padding on marketing pages.

Paste this in Lovable chat

Pro tip: In Agent Mode (the default), @file references give the AI direct file context. In Plan Mode, use @file references the same way — Plan Mode creates a formal plan before making changes, which is useful for large config rewrites you want to review first.

Expected result: tailwind.config.ts is updated with only the spacing values you specified, without disturbing other theme settings. You can immediately use classes like p-18, mt-22, and gap-26 in your components.

Common use cases

Apply a brand color palette across an entire Lovable app

You have a brand guide with specific hex codes for primary, secondary, accent, and neutral colors. You want every button, link, badge, and background in your Lovable app to use those exact values instead of Tailwind's defaults. Updating tailwind.config.ts and the shadcn CSS variables propagates the change everywhere in one step.

Lovable Prompt

Update the Tailwind theme to use our brand colors: primary #1D4ED8, secondary #7C3AED, accent #F59E0B, background #F9FAFB, and text #111827. Update tailwind.config.ts and the CSS variables in index.css so shadcn components use these colors too.

Copy this prompt to try it in Lovable

Add a custom font family from Google Fonts

The default Tailwind font stack uses system fonts. For a polished product, you want to load a specific Google Font like Inter or Geist and configure it as the default font in your Tailwind theme so every text element uses it automatically without adding font-inter classes everywhere.

Lovable Prompt

Add Inter from Google Fonts to this project. Configure it as the default sans-serif font in tailwind.config.ts so all text uses Inter automatically. Include the font import in index.css or index.html.

Copy this prompt to try it in Lovable

Configure tailwindcss-animate for smooth UI transitions

shadcn/ui components like dialogs, dropdowns, and tooltips use animation classes that require tailwindcss-animate to be registered as a Tailwind plugin. If these components are rendering without animations or showing errors about missing keyframe utilities, the plugin needs to be added to tailwind.config.ts.

Lovable Prompt

Add the tailwindcss-animate plugin to tailwind.config.ts so shadcn dialog and dropdown components animate correctly. Make sure the package is installed and the plugin is registered in the plugins array.

Copy this prompt to try it in Lovable

Troubleshooting

Custom color classes like bg-brand-500 are applied in JSX but the element shows no background color in the browser.

Cause: Tailwind's production build scans source files to determine which utility classes to include in the CSS bundle. If your custom color key is not used in any file matching the content glob in tailwind.config.ts, Tailwind purges the class and it produces no output. This also happens when class names are constructed dynamically with string concatenation (e.g., 'bg-' + colorName) — Tailwind cannot detect these at build time.

Solution: Verify the content array in tailwind.config.ts includes the paths where you use the custom classes (the typical Lovable config includes './src/**/*.{ts,tsx}'). For dynamically constructed class names, add a safelist array to tailwind.config.ts listing those classes explicitly, or switch to using complete static class names in your JSX source.

typescript
1// In tailwind.config.ts — add safelist for dynamic or generated classes
2module.exports = {
3 content: ['./src/**/*.{ts,tsx}'],
4 safelist: [
5 'bg-brand-500',
6 'bg-brand-600',
7 'text-brand-50',
8 // Or use a pattern to safelist a range:
9 { pattern: /bg-brand-(\d+)/ },
10 ],
11 theme: { extend: {} },
12 plugins: [],
13};

After adding a new color to tailwind.config.ts, shadcn/ui components like Button and Badge still show the old default blue color.

Cause: shadcn/ui components do not read colors directly from tailwind.config.ts. They reference CSS custom properties defined in src/index.css using HSL values (for example, --primary: 221.2 83.2% 53.3%). Adding a color to tailwind.config.ts creates new utility classes but does not change the --primary variable that shadcn components use via the bg-primary class.

Solution: Open src/index.css and update the CSS custom properties under the :root selector to match your new brand color. Convert your hex color to HSL format — ask Lovable to perform this conversion for you as part of the same prompt. The --primary value controls button backgrounds, --primary-foreground controls button text, and --ring controls focus ring color.

typescript
1/* In src/index.css — update shadcn color variables to match new brand */
2:root {
3 /* Primary: #2563EB converts to roughly hsl(221, 83%, 53%) */
4 --primary: 221 83% 53%;
5 --primary-foreground: 0 0% 100%;
6
7 /* Destructive: matches rose-600 */
8 --destructive: 347 77% 50%;
9 --destructive-foreground: 0 0% 100%;
10
11 /* Ring follows primary for accessible focus indicators */
12 --ring: 221 83% 53%;
13}

Tailwind build fails with 'Cannot find module tailwindcss-animate' or shadcn dialog and dropdown animations are missing after deployment.

Cause: The tailwindcss-animate package is listed in tailwind.config.ts plugins but was not installed in package.json, or it is only in devDependencies and is unavailable in the production build environment.

Solution: Ask Lovable to add tailwindcss-animate to package.json dependencies (not devDependencies) and verify the import in tailwind.config.ts uses the correct ESM import syntax. Lovable's build process runs Tailwind as part of the Vite build, so the package must be resolvable in the build context.

typescript
1// tailwind.config.ts — correct ESM import for .ts config files
2import animate from 'tailwindcss-animate';
3
4// NOT: const animate = require('tailwindcss-animate') — use ESM import
5
6export default {
7 plugins: [animate],
8};

Dark mode classes like dark:bg-slate-900 have no visible effect even though the dark class appears to be active.

Cause: Lovable's default tailwind.config.ts uses darkMode: ['class'], which requires the dark class on the html element specifically. The dark class applied to document.body, a container div, or any element other than the html element will not trigger Tailwind's dark mode selector.

Solution: Verify your dark mode toggle targets document.documentElement (the html element) rather than document.body or a child container. Inspect the html element in browser DevTools to confirm the dark class appears there. If you use a shadcn ThemeProvider, it handles this automatically — ask Lovable to add a proper ThemeProvider with a toggle component if dark mode handling is not yet implemented.

typescript
1// Correct: apply dark class to the html element
2document.documentElement.classList.toggle('dark');
3
4// Incorrect: these do NOT activate Tailwind dark: variants
5document.body.classList.toggle('dark');
6document.getElementById('app')?.classList.toggle('dark');

Best practices

  • Always use theme.extend.colors instead of theme.colors when adding custom colors — omitting 'extend' replaces the entire default Tailwind palette and removes all built-in color utilities like blue, red, gray, and slate.
  • Keep design tokens in tailwind.config.ts as the single source of truth. Avoid hardcoding hex values directly in className strings — define them in the config and reference them as utility classes so a single config change propagates everywhere.
  • When customizing colors for shadcn/ui components, update both tailwind.config.ts and the CSS custom properties in src/index.css. The config controls utility class generation; index.css controls the default values shadcn components render via the bg-primary and text-foreground classes.
  • Use semantic color names in your config (brand, primary, surface, error) rather than literal color names (blue-500, violet-600). Semantic names survive redesigns — if your primary color shifts from blue to purple, you update one config value instead of searching the entire codebase.
  • Never construct Tailwind class names with string concatenation like 'bg-' + color. Tailwind's scanner cannot detect dynamic class names and will purge them from the production bundle, making styles invisible in production while appearing to work in development.
  • Test Tailwind config changes in both light and dark mode if your app supports theming. CSS custom properties in :root may need matching overrides in the .dark selector block in index.css for shadcn components to theme-switch correctly.
  • Use the @tailwindcss/typography plugin and the prose class for any page rendering rich text content — blog posts, documentation, legal pages. It handles heading hierarchy, list spacing, and code block styling automatically instead of requiring dozens of per-element utility classes.
  • For large-scale design system implementations with many custom tokens and multiple plugin configurations, use Lovable's Plan Mode to review the proposed tailwind.config.ts changes before applying them. Plan Mode never modifies code, letting you validate the approach before committing.

Alternatives

Frequently asked questions

Do I need to install Tailwind CSS in my Lovable project?

No. Tailwind CSS is installed and configured automatically in every Lovable project — you did not set it up and cannot turn it off. The tailwind.config.ts file is already present at the project root and the Vite build pipeline processes it on every build. Your only task is customizing the config if your brand design requires specific colors, fonts, or spacing beyond Tailwind's defaults.

Why do my custom Tailwind colors work in the Lovable preview but disappear after publishing?

This is Tailwind's production purging behavior. In development, Tailwind includes all possible utility classes. In production builds, it scans your source files and removes any classes not found in the code. If your class names are constructed dynamically with string concatenation like 'bg-' + colorName, Tailwind cannot detect them and purges them. Use complete static class names in your JSX (bg-brand-500) or add them to the safelist array in tailwind.config.ts to force their inclusion in the production bundle.

How do I find the HSL values I need for the shadcn CSS variables in index.css?

shadcn/ui uses CSS custom properties in HSL format without the hsl() wrapper — for example, --primary: 221 83% 53% rather than --primary: hsl(221, 83%, 53%). To convert a hex color to this format, ask Lovable directly: 'Convert #2563EB to the HSL format used by shadcn CSS variables in index.css.' Lovable computes the correct values and writes the update for you. You can also inspect computed HSL values using browser DevTools on any element that uses a standard shadcn component.

Can I use Tailwind v4 in a Lovable project?

Lovable's generated projects use Tailwind CSS v3 with a tailwind.config.ts file. Tailwind v4 uses a completely different configuration approach based on CSS @theme directives rather than a JavaScript config file, and shadcn/ui has not fully migrated to v4 as of early 2026. Attempting to upgrade to v4 manually will break the build and the shadcn/ui component configuration. Stay on v3 unless Lovable explicitly supports v4 in a future update.

Can I remove Tailwind and use a different CSS framework in Lovable?

It is technically possible but not practical. Lovable's AI generates all component code using Tailwind utility classes, and shadcn/ui components are built entirely on Tailwind. Replacing Tailwind with another framework would require rewriting every className attribute in every generated component — a massive manual effort that also breaks Lovable's AI-assisted generation going forward. The practical approach is to customize Tailwind to match your design system rather than replace it.

How do I add a dark mode toggle to my Lovable app?

Ask Lovable to add a theme toggle component. Lovable's tailwind.config.ts uses darkMode: ['class'], which activates dark mode when the dark class is on the html element. Lovable will generate a toggle button that adds the class to document.documentElement and stores the preference in localStorage. The shadcn/ui ThemeProvider is the standard implementation — prompt Lovable with 'Add a dark mode toggle using shadcn ThemeProvider that persists the user preference in localStorage.'

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.