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.
themes/acme/login/
theme.properties
resources/css/custom.css
messages/messages_en.properties# Extends the classic login theme and keeps its stylesheet.
parent=keycloak
import=common/keycloak
styles=css/login.css css/custom.cssThe 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
- Enter a theme name in lower case, without spaces.
- Pick the parent theme.
- Set your brand color and the sign-in title.
- Copy the shell script and run it in an empty folder, or copy each file.
- Run Keycloak with
start-devand the theme folder mounted, then pick the theme under Realm settings, Themes. - Edit the CSS and reload the page until it looks right.
- Build an image with the Dockerfile for production.
FROM quay.io/keycloak/keycloak:26.8.1
COPY themes/acme /opt/keycloak/themes/acmeWhat 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.