Skip to content

Keycloak login theme scaffold

Generate the folder layout, theme.properties, stylesheet and message file for a custom Keycloak login theme, as files or as a JAR.

Runs in your browser. Nothing you paste is sent to us.

Theme

Lower case, no spaces. It is the folder name and what you pick in the realm’s settings.

26.8.1 is the version we run. Edit it to your version.

Files

theme.properties
themes/acme/login/theme.properties
custom.css
themes/acme/login/resources/css/custom.css
messages_en.properties
themes/acme/login/messages/messages_en.properties
login/theme.properties
# Extends the classic login theme and keeps its stylesheet.
parent=keycloak
import=common/keycloak
styles=css/login.css css/custom.css
css/custom.css
/* Your changes on top of the parent theme. */
:root {
  --acme-brand: #1f4fd8;
}

/* Example: tint the primary button. Inspect the login page to find the
   selectors your Keycloak version uses. */
.btn-primary,
.pf-c-button.pf-m-primary,
.pf-v5-c-button.pf-m-primary {
  background-color: var(--acme-brand);
  border-color: var(--acme-brand);
}
messages/messages_en.properties
# Overrides for the English texts. Keys not listed keep the parent's text.
loginAccountTitle=Sign in to Acme
doLogIn=Sign in
Or create them all with this shell script
#!/bin/sh
# Creates the theme files in the current folder.
set -e
mkdir -p 'themes/acme/login'
cat > 'themes/acme/login/theme.properties' <<'THEME_EOF'
# Extends the classic login theme and keeps its stylesheet.
parent=keycloak
import=common/keycloak
styles=css/login.css css/custom.css
THEME_EOF
mkdir -p 'themes/acme/login/resources/css'
cat > 'themes/acme/login/resources/css/custom.css' <<'THEME_EOF'
/* Your changes on top of the parent theme. */
:root {
  --acme-brand: #1f4fd8;
}

/* Example: tint the primary button. Inspect the login page to find the
   selectors your Keycloak version uses. */
.btn-primary,
.pf-c-button.pf-m-primary,
.pf-v5-c-button.pf-m-primary {
  background-color: var(--acme-brand);
  border-color: var(--acme-brand);
}
THEME_EOF
mkdir -p 'themes/acme/login/messages'
cat > 'themes/acme/login/messages/messages_en.properties' <<'THEME_EOF'
# Overrides for the English texts. Keys not listed keep the parent's text.
loginAccountTitle=Sign in to Acme
doLogIn=Sign in
THEME_EOF
Dockerfile
FROM quay.io/keycloak/keycloak:26.8.1
COPY themes/acme /opt/keycloak/themes/acme
Try it
Run Keycloak with start-dev while you work: it does not cache themes, so a page reload shows your changes. Then choose acme as the login theme under Realm settings, Themes.

How to use it

  1. Name the theme and pick the parent theme to extend.
  2. Set a brand color and the sign-in title.
  3. Create the files with the shell script, or copy them one by one.
  4. Build an image with the Dockerfile, or copy the folder into themes.
  5. Choose the theme under Realm settings, Themes.

What to know

A login theme extends a parent and overrides only what it needs: a stylesheet, a few messages, or templates. Extending keeps your theme working when Keycloak updates its own pages.

theme.properties names the parent and the stylesheets. Listing styles replaces the parent’s list, so keep the parent’s files in it and add yours at the end.

While you work, run Keycloak with start-dev, which does not cache themes, so a reload shows each change.

What a Keycloak login theme is

A theme controls how Keycloak’s pages look. The login theme covers the sign-in page and everything around it: registration, password reset, one-time code setup, required actions and error pages. Other theme types cover the account console, the admin console, emails and the welcome page.

A theme is a folder of files. It names a parent theme, adds stylesheets, images and messages, and can override page templates. Keycloak picks the theme per realm, and a client can set its own login theme.

This tool writes the starting files for a login theme that extends one of Keycloak’s own. You add your styles and text, and keep everything else from the parent.

Why it matters in production

The sign-in page is often the first screen users see from your product. A page that looks like your app, with your name and colors, tells users they are in the right place. That matters for trust and for spotting phishing pages that copy the default look.

A theme that extends a parent stays small. When Keycloak updates its pages, your theme picks up the changes and only your overrides need checking. A theme that copies every template becomes a fork you have to update by hand after each upgrade.

How Keycloak 26 finds and loads themes

Keycloak loads themes from two places: the themes folder of the installation, and JAR files in the providers folder. In the official container image those are /opt/keycloak/themes and /opt/keycloak/providers.

Inside a theme, each type has its own folder, such as login. Its theme.properties names the parent and the stylesheets. Files you do not provide come from the parent.

The folder layout for a sample theme named acme
themes/acme/login/
  theme.properties
  resources/css/custom.css
  messages/messages_en.properties
theme.properties for the classic parent
# Extends the classic login theme and keeps its stylesheet.
parent=keycloak
import=common/keycloak
styles=css/login.css css/custom.css

The styles line replaces the parent’s list of stylesheets. That is why the line above keeps css/login.css from the parent and adds css/custom.css at the end.

Choosing a parent

The tool offers two parents. keycloak is the classic set of login pages. keycloak.v2 is the newer set. The base theme has templates but no styling, so it is rarely a good parent for a branded theme.

For keycloak.v2, the tool leaves the styles line commented out. Copy the line from keycloak.v2’s own theme.properties in your Keycloak version and add css/custom.css to its end. Without it, your stylesheet is not loaded.

Messages

Texts on the pages come from message bundles. A messages_en.properties file in your theme overrides only the keys it lists, such as loginAccountTitle or doLogIn. Add files for other languages the same way.

Templates

The pages are FreeMarker templates with the .ftl extension. You can override one by copying it from the parent into your theme. Once copied, it is yours to keep up to date, so override templates only when styles and messages are not enough.

What this tool does and does not do

The scaffold writes three files: theme.properties, a stylesheet with your brand color, and an English message file with your sign-in title. It also writes a shell script that creates them all, and a Dockerfile that adds the theme to the Keycloak image.

With the JAR option, it moves the files under src/main/resources/theme/ and adds META-INF/keycloak-themes.json, which tells Keycloak which themes the JAR holds.

It does not write templates, build a JAR or test the theme. The CSS selectors in the stylesheet are examples: inspect the sign-in page in your Keycloak version to find the ones you need. The image tag in the Dockerfile is the version we run; change it to yours.

How to use the scaffold

  1. Enter a theme name in lower case, without spaces.
  2. Pick the parent theme.
  3. Set your brand color and the sign-in title.
  4. Copy the shell script and run it in an empty folder, or copy each file.
  5. Run Keycloak with start-dev and the theme folder mounted, then pick the theme under Realm settings, Themes.
  6. Edit the CSS and reload the page until it looks right.
  7. Build an image with the Dockerfile for production.
A Dockerfile for the sample theme; set the tag to your version
FROM quay.io/keycloak/keycloak:26.8.1
COPY themes/acme /opt/keycloak/themes/acme

What to change first

Most teams get what they need from a few small changes. Start with these, in this order, and stop when the page looks right.

  • Colors: the primary button, links and focus outlines, set in your stylesheet.
  • Logo: an image in resources/img, shown with a CSS rule on the page header.
  • Title and wording: the sign-in title and button text, set in the message file.
  • Background: a plain color or a light image, kept subtle so the form stays readable.

Each of these lives in CSS or messages, so none of them needs a template override. Check color contrast as you go: text on your brand color must stay readable for everyone, including users with low vision.

Developing without restarts

In production mode, Keycloak caches themes, so edits do not show until a restart. Development mode, started with kc.sh start-dev, turns theme caching off. Mount your theme folder into the container and a page reload shows each change.

Keep a test realm for theme work, with a test user that has OTP set up and a few required actions. That way you can see every page the theme touches, not only the sign-in form.

Use cases

First production deploy

Ship a light theme: logo, colors and the sign-in title. Leave templates alone. It looks like your product and survives upgrades.

Several brands on one server

Each realm can use its own login theme, and a client can override the realm’s choice. One Keycloak can then show different brands to different apps.

Upgrade from an older version

Themes built years ago often copy many templates. After an upgrade, compare each copied template with the new parent, or drop the copies and move the changes into CSS and messages.

Moving to Kubernetes

Build the theme into your Keycloak image rather than mounting it at run time. Every pod then has the same theme, and a rollback brings the old theme back with the old image.

Common errors and fixes

The theme is missing from the list

Keycloak did not find it. Check the folder path, that theme.properties sits in the type folder, and for a JAR that META-INF/keycloak-themes.json names the theme and type. Restart Keycloak after adding a theme in production mode.

The page lost all its styling

The styles line replaced the parent’s stylesheets. Put the parent’s files back at the start of the line.

Changes do not show

Production mode caches themes. Use start-dev while you work, or restart after each change. Also clear the browser cache.

Pages broke after an upgrade

A copied template no longer matches what the new version expects. Compare it with the parent’s template and update it, or remove it.

Security notes

  • Do not load scripts or fonts from third-party hosts on the sign-in page. Anything it loads can see what users type.
  • Keep the parent’s security-related markup when you override templates.
  • Review theme changes like code: the sign-in page handles passwords.

Best practices

  • Extend a parent; never copy a whole theme.
  • Prefer CSS and messages over template overrides.
  • Keep the theme in version control and build it into your image.
  • Test every page type, not only the sign-in form.
  • Check the theme on a phone-sized screen.

Managed hosting and custom themes

Custom themes and extensions are not supported in RealmDeploy managed tenants yet. Every cluster runs the stock Keycloak image, so realms there use Keycloak’s built-in themes. If your realms depend on a custom theme, keep that in mind when you compare our plans.

Questions

Frequently asked questions

Where do Keycloak themes go?

In the `themes` folder of the Keycloak installation, which is `/opt/keycloak/themes` in the container. You can also package themes in a JAR and put it in the `providers` folder.

How do I make a custom Keycloak login theme?

Create a folder with a `login` subfolder and a `theme.properties` that names a parent such as `keycloak`. Add your stylesheet and messages, then pick the theme under Realm settings, Themes.

Why does my Keycloak theme not change after I edit it?

Production mode caches themes. Use `start-dev` while you develop, which turns caching off, or restart the server after a change.

Which parent should a login theme extend?

`keycloak` for the classic login pages or `keycloak.v2` for the newer ones. The base theme has no styling, so it is rarely the right parent.

How do I change the text on the Keycloak sign-in page?

Add a `messages_en.properties` file to your theme with the keys you want to change, such as `loginAccountTitle`. Keys you leave out keep the parent’s text.

Can each client have its own login theme?

Yes. A client can set a login theme that overrides the realm’s. That lets one realm show different brands to different apps.

How do I package a Keycloak theme as a JAR?

Put the theme under `theme/<name>/login` in the JAR and add `META-INF/keycloak-themes.json` naming the theme and its types. Copy the JAR into `providers` and run `kc.sh build`.

Can I use a custom theme on RealmDeploy?

Not yet. Our managed tenants run the stock Keycloak image, so realms use Keycloak’s built-in themes.

Rather not run Keycloak yourself?

We run it for you on a cluster of your own, with backups, upgrades and written support. Starter and Premium begin with a 7-day trial.