Style FusionAuth Themes with Tailwind CSS
On this page
When your application uses Tailwind CSS, you can use the same Tailwind CSS classes in an advanced theme. The Tailwind CSS build scans the theme templates for class names and writes the stylesheet that the hosted login pagesThe login, registration, password recovery, and multi-factor authentication pages that FusionAuth serves. A Theme controls the look of the pages. use. The FusionAuth CLI uploads the templates and the stylesheet to FusionAuth.
This guide covers Tailwind CSS 4 and Tailwind CSS 3. Tailwind CSS 4 supports Safari 16.4 and later, Chrome 111 and later, and Firefox 128 and later. When the users of your login pages need older browsers, use Tailwind CSS 3.
Prerequisites#
- Node.js 20 or later
Set Up FusionAuth#
-
Navigate to Customization -> Themes and click Add . Enter a Name for the theme and click Save .

-
Navigate to Settings -> API Keys and click Add . Select the
GETandPATCHpermissions for/api/theme/, and click Save .
Create the Project#
-
Create a Node.js project, and install the FusionAuth CLI and Tailwind CSS:
$ mkdir fusionauth-tailwind $ cd fusionauth-tailwind $ npm init -y $ npm install @fusionauth/cli tailwindcss @tailwindcss/cli -
Create
input.cssin the project root. The file imports Tailwind CSS, and@sourceadds the FreeMarker templates in thetpldirectory to the build. Add your own classes to this file:@import "tailwindcss"; @source "./tpl"; -
Add the following scripts to
package.json. Replace<themeId>and<apiKey>with the Id of the theme and the API key:"scripts": { "watch:tailwind": "tailwindcss -i ./input.css -o ./tpl/stylesheet.css --watch", "watch:theme": "fusionauth theme:watch <themeId> -k <apiKey> -h http://localhost:9011" },
-
Create a Node.js project, install the FusionAuth CLI and Tailwind CSS, and create a Tailwind CSS configuration file:
$ mkdir fusionauth-tailwind $ cd fusionauth-tailwind $ npm init -y $ npm install @fusionauth/cli tailwindcss@3 $ npx tailwindcss init -
Set
contentintailwind.config.jsto the FreeMarker templates in thetpldirectory:/** @type {import('tailwindcss').Config} */ module.exports = { content: ['./tpl/*.ftl'], theme: { extend: {} }, plugins: [] } -
Create
input.cssin the project root. The file imports the Tailwind CSS base styles, components, and utilities. Add your own classes to this file:@tailwind base; @tailwind components; @tailwind utilities; -
Add the following scripts to
package.json. Replace<themeId>and<apiKey>with the Id of the theme and the API key:"scripts": { "watch:tailwind": "tailwindcss -i ./input.css -o ./tpl/stylesheet.css --watch", "watch:theme": "fusionauth theme:watch <themeId> -k <apiKey> -h http://localhost:9011" },
Prepare the Theme#
-
Download the theme. Replace
<themeId>and<apiKey>again:$ npx fusionauth theme:download <themeId> -k <apiKey> -h http://localhost:9011The CLI writes the templates to
.ftlfiles in thetpldirectory, and the stylesheet totpl/stylesheet.css. -
Remove the
linktag for the default FusionAuth stylesheet from theheadmacro intpl/helpers.ftl. The default styles conflict with Tailwind CSS. Recent themes linkfusionauth-hosted.css:<link rel="stylesheet" href="${request.contextPath}/css/entrypoints/fusionauth-hosted.css?version=${version}"/>Older themes link
fusionauth-style.cssinstead. -
Upload the theme to apply the change to
tpl/helpers.ftl:$ npx fusionauth theme:upload <themeId> -k <apiKey> -h http://localhost:9011
Edit the Theme#
Run each of the following scripts in a separate terminal:
npm run watch:tailwindrebuildstpl/stylesheet.csswhen a template changes.npm run watch:themeuploads the templates and the stylesheet to FusionAuth when a file in thetpldirectory changes.
When a template uses a Tailwind CSS class, the build adds the class to the stylesheet:
<div class="bg-gray-200">
<h1 class="text-2xl">Hello World</h1>
</div>
To preview the theme, navigate to Customization -> Themes , choose the theme, and click .


When the application also uses React, you can copy the markup of the application's components into the templates. For more information, see Match FusionAuth Themes to a React Application.
Add DaisyUI#
DaisyUI is a Tailwind CSS plugin with prebuilt components, color themes, light and dark modes, and right-to-left support. DaisyUI 5 requires Tailwind CSS 4. With Tailwind CSS 3, use DaisyUI 2, which the FusionAuth example DaisyUI theme uses.
The example theme sets up light and dark modes, and includes templates for the following pages:
- Log in
- Log out
- Registration
- Forgot password
-
Install the plugin:
$ npm install daisyui -
Add the plugin to
input.css:@import "tailwindcss"; @source "./tpl"; @plugin "daisyui";
To use the color scheme of the example theme, set the themes in input.css. --default sets the light theme, and --prefersdark sets the theme for browsers in dark mode. The daisyui/theme block changes the primary color of the business theme, and the @theme block adds the progress bar animation that the example templates use:
@import "tailwindcss";
@source "./tpl";
@plugin "daisyui" {
themes: corporate --default, business --prefersdark;
}
@plugin "daisyui/theme" {
name: "business";
prefersdark: true;
--color-primary: #c891f2;
}
@theme {
--animate-progressBar: progressBar 10s ease-in 1;
@keyframes progressBar {
0% { width: 0%; }
100% { width: 100%; }
}
}
-
Install the plugin:
$ npm install daisyui@2 -
Add the plugin to
tailwind.config.js:module.exports = { content: ['./tpl/*.ftl'], theme: { extend: {} }, plugins: [ require('daisyui') ] }
To change the color scheme of the example theme, edit daisyui.themes and daisyui.darkTheme in tailwind.config.js:
21 hidden lines/** @type {import('tailwindcss').Config} */module.exports = { content: ['./tpl/*.ftl'], theme: { extend: { keyframes: { progressBar: { "0%": { width: "0%" }, "100%": { width: "100%" } } }, animation: { progressBar: "progressBar 10s ease-in 1" } } }, plugins: [require("daisyui")], daisyui: { themes: [ 'corporate', { business: { ...require("daisyui/src/colors/themes")["[data-theme=business]"], 'primary': '#c891f2' } } ], darkTheme: 'business' }}Use DaisyUI components in the templates:
<div class="bg-gray-200">
<h1 class="text-2xl">Hello World</h1>
<div class="p-4">
<button class="btn btn-primary">Primary</button>
</div>
</div>
To create a color theme, use the DaisyUI Theme Generator.
Related
Learn about the APIs for creating, retrieving, updating, and deleting hosted login page themes.
Learn how to make the FusionAuth hosted login pages match a React application.
Quickly and easily style FusionAuth with no code.
Learn about the APIs for creating, retrieving, updating, and deleting simple themes for hosted login pages.