Customizing the Keycloak login theme

Customizing the Keycloak login theme lets you brand sign-in pages without forking the server, provided you keep overrides small enough to survive upgrades. This page covers the options, build sequence, security checks and cost drivers.

On this page

Why teams customize the Keycloak login theme and when it is worth it

A company putting Keycloak in front of customer or workforce applications usually needs the sign-in pages to look like its own products, not like a generic identity server. A login theme is the way to do that. In Keycloak, a theme is a set of FreeMarker templates and stylesheets that render the login, registration, password reset, one-time code and error pages, and the other screens users see before they reach your application. You need a custom theme when the built-in realm settings, such as a logo, a background color or a display name, cannot express the branding or the page structure you require. If those settings cover your needs, keep them, because every change beyond them is code your team will carry through upgrades.

The theme is part of the Keycloak server you run, not a separate product. Keycloak is licensed under Apache 2.0, so you can read, modify and redistribute the theme files as your organization's own code, and the license imposes no fee for doing so. The cost is operational: your theme is deployed alongside a specific Keycloak version, so each upgrade may require you to check whether the templates or stylesheets you changed still match the new release. Before committing to a custom theme, confirm with your team which of your sign-in screens must differ from the default, which screens can stay as shipped, and who will review theme changes when the Keycloak release line moves forward.

A useful first decision is how far the design needs to go. Overriding stylesheets while keeping the default templates is the lightest option and tends to survive upgrades best. Overriding templates changes markup and form behavior, so every template you touch becomes a point to retest after each release. Ask your design and security teams to list the screens and fields they need to change, then mark each one as a style change or a structure change. The shorter that second list, the cheaper the theme will be to keep working, and it is the list you should bring to any partner when you ask for a quote.

Choosing between stylesheet overrides, template overrides and a new theme

A stylesheet override keeps the parent theme's templates and changes only the CSS that styles them. You create a theme that declares a parent, add a theme.properties file and a custom stylesheet, and Keycloak loads your rules after the parent's. Colors, fonts, spacing, logo placement and button styling are usually reachable this way, so most branding requests can be met without touching page structure.

  • What changes: Only CSS and static assets such as logos and images. The HTML structure, form fields and messages come from the parent theme.
  • What breaks on upgrade: Rules that target generated class names or element structure can stop matching when the parent markup changes. Visual regressions are the most common result, and they are usually easy to spot.
  • Who maintains it: Usually the team that owns branding or the platform team. Upkeep is mostly a visual check after each upgrade.
  • Cost driver: The number of selectors you override. A short stylesheet is cheap to retest; a long one that restyles every element is not.
  • Ask your partner: Which selectors they will target, and how they will confirm the pages still render after a minor release.

Before committing to a stylesheet-only design, confirm with your branding owner that the required layout can be achieved by CSS alone.

Login theme options and when each fits

This table compares the five main ways to change Keycloak's login pages, from a child theme of the default to per-client themes. Read each row for the upgrade exposure it creates and the kind of branding work it suits. The main takeaway is that the more of the default templates you replace, the more each Keycloak upgrade will cost you to review.

OptionUpgrade exposureTypical use
Child theme extending the default themeLow to moderate. The child inherits default templates and resources, so you review only what you override when upgrading.Brand the login page with a few template changes while keeping the default structure and behavior.
Override CSS and static resources onlyLow. Stylesheets, images and scripts are replaced without touching FreeMarker markup, so structural changes in new releases are less likely to break the page.Change colors, fonts, logos and spacing when the existing page layout already fits your needs.
Override specific FreeMarker templatesHigh for each template overridden. Markup and form field names must be re-checked against the new Keycloak version before every upgrade.Change page structure, add content blocks or alter form layout that CSS alone cannot reach.
Set a login theme per realmLow on its own. The choice is a realm setting, but the theme you pick carries the exposure of its own overrides.Separate brands for different customer groups or business units that share one Keycloak server.
Set a login theme per clientLow on its own. Client-level selection adds more themes to test, so each extra theme repeats the upgrade review.Show a different sign-in look for specific applications while the realm keeps one default.
Package the theme as a JARNeutral on exposure. Packaging changes how the theme is deployed, not how much it must be reviewed after an upgrade.Deliver the same theme consistently to every node in a clustered deployment.
Keep overrides minimal across all optionsLowest when the override set is small and documented. Confirm each override against the Keycloak release notes before upgrading.Standard practice for any long-lived production theme.

How to build, package and deploy a custom login theme

This sequence takes a login theme from an empty directory to a tested, selected theme in a realm, with an optional per-client override. Each step ends with a check so the team knows the theme is working before the next layer is added.

  1. Create the theme directory structure

    Create a theme folder named for your brand, with a login directory inside it. Add a theme.properties file in that directory and set parent=keycloak so the custom theme inherits the default templates and only the files you add or override take effect. Keep the folder name lowercase and free of spaces, because it becomes the name you select in the realm. Check that the folder tree matches what the server expects before you add any content, and confirm the parent value against the theme documentation for the Keycloak version you run.

  2. Add stylesheets and static resources

    Place your CSS in a resources/css folder and list it under the styles key in theme.properties so the login pages load it after the parent styles. Add logos, fonts and images under resources/img or a similar folder and reference them from the stylesheet. Start with stylesheet overrides because they change the look of every login page without touching FreeMarker templates, which keeps upgrade work small. Check the result by loading the theme once (see the later steps) and confirming that your colors and logo appear on the login form.

  3. Override only the templates you need

    Copy the specific FreeMarker template you must change, such as login.ftl for the sign-in form, from the parent theme into your login folder and edit only that file. Every copied template is a file you must compare and merge during each Keycloak upgrade, so record which templates you changed and why. Avoid copying templates to change wording that a message bundle can handle. Check that each overridden template renders, and keep a short list of overridden files in your repository so reviewers can see the upgrade exposure at a glance.

  4. Package the theme as a JAR

    Package the theme folder into a JAR so the server can load it as a provider. The theme directory must sit at the root of the archive under theme/ with the theme name beneath it, and the build should produce a single JAR with no extra nesting. Use your build tool of choice and confirm the layout by listing the archive contents before deployment. Check that the JAR contains theme.properties, your stylesheets and any overridden templates at the paths you expect.

  5. Deploy the JAR to the Keycloak server

    Copy the JAR into the server's providers directory, then rebuild the server with kc.sh build if your deployment mode requires it, and restart it. In containers, add the JAR to the image build or mount it into the provider path, and let your deployment pipeline handle the rebuild. Confirm that the server starts without provider errors in its log output, then confirm the theme is available by checking the server's theme list in the admin console. Record the exact Keycloak version alongside the JAR so you can retest the theme after every upgrade.

  6. Select the theme in the realm

    In the admin console, open the target realm, go to Realm settings, and choose your theme for the login theme field. Save the change, then open the realm's login page in a private browser session. Confirm that the admin console shows your theme as the selected login theme and that the login page displays your stylesheet and logo. If the page still shows the default look, clear any cached assets and check that you selected the correct realm.

  7. Apply a per-client login theme if needed

    Only use a per-client login theme when one application needs a different look, such as a partner-branded sign-in. Confirm that your Keycloak version supports the client-level theme setting in the current documentation before you rely on it, because this behavior changes between releases. Set the theme on the specific client and verify that the sign-in page for that client uses it while other clients keep the realm theme. Check both paths in separate browser sessions so cached settings do not hide a mistake.

  8. Test every login path before release

    Test each sign-in route your users rely on: username and password, passkey or OTP prompts, password reset, required actions, error messages, and any identity provider button. Run the tests in a private browser session for each theme and client combination, and include a mobile-sized viewport and at least one non-default language. Record the results and any template that failed, then repeat the tests after each Keycloak upgrade. The release is ready when every path renders with the intended theme and none of them returns an unstyled or broken page.

How Keycloak resolves which login theme a user sees

The flow starts when a browser requests the login page for a realm and client through the reverse proxy, which is the trust boundary before requests reach the Keycloak server. Keycloak checks whether the client has its own login theme, falls back to the realm login theme when it does not, then loads the packaged theme with its parent chain. FreeMarker templates and stylesheets from that chain render the page. Check the proxy path rules and that each theme in the chain is deployed where the server can find it.

Theme selection from browser request to rendered login page, with the proxy trust boundary.

How to keep template overrides from raising upgrade costs

A login theme breaks on upgrade in proportion to how much of Keycloak's own templates it copies and how little it tracks. The practices below reduce that exposure, and each one makes the next upgrade a smaller, testable task rather than a rebuild of the login pages.

Prefer stylesheets over template copies

Change colors, fonts, spacing and logos through CSS and static resources wherever the design allows. Stylesheet rules keep working when Keycloak changes markup in a later release, while a copied FreeMarker template keeps the old markup until someone merges it by hand. Before copying a template, list what you need to change and check whether a stylesheet or resource override can do it.

Keycloak docs

Keep copied templates minimal

When a template must be copied, change only the blocks that need it and leave the rest as Keycloak ships it. A short copy has fewer lines to reconcile against each new release. Record the reason for every copied file in the theme's README so a reviewer can tell whether the change is still needed after an upgrade.

Track overridden templates per release

Keep a register of every template the theme overrides, mapped to the Keycloak version it was copied from. Before each upgrade, diff the upstream version of each listed file against the copy. A file that changed upstream is a known merge task, and a file that did not change needs no review. Ask whoever owns the theme to keep this register current as part of each change.

Pin the parent theme and test release candidates

Set the theme's parent explicitly rather than relying on a default, so a server upgrade does not silently change the base the theme inherits from. Test the theme against each release candidate in a non-production realm before the production upgrade. The parent setting is the first thing to check when login pages change after an upgrade that the theme did not touch.

Keep theme code in version control

Store the theme source, the packaged JAR build steps and the deployment configuration in the same repository as the rest of the identity configuration. Tag the theme version that matches each server release. Without version control, rolling back a broken login page means rebuilding from memory, and the diff between the old and new theme cannot be reviewed.

Automate a login regression run

Script the login paths that matter, including password sign-in, MFA prompts, password reset, error messages and the logout redirect, and run them against a staging instance after every upgrade and theme change. Automated checks catch a broken button or a missing field within minutes, which manual review of a few screens often misses. Confirm with your security team which flows must pass before a release proceeds.

What customizing a Keycloak login theme costs and requires

What drives the cost of a Keycloak login theme project?

The main drivers are how many pages you brand, how many languages the pages must support, whether each client or realm needs its own look, and how many template overrides the design requires. A stylesheet-only change on the login page is a small job. A set of overridden templates for login, account, error and email pages across several languages is a much larger one. Ask any quote to break the work down by page type, language and client, and to state how many FreeMarker templates it expects to override and why each one cannot be handled with CSS or message properties.

How long does a Keycloak login theme take to build?

Duration follows scope. The number of pages, the number of language variants, the number of clients with their own branding and the amount of template work all add time, and design review and sign-off often add more than the coding. No duration figure is supplied for this work, so ask for a timeline tied to a written list of deliverables and a named test environment. A quote that cannot point to the pages and templates it covers is not yet a schedule you can check.

Who does what in an internal build compared with a partner build?

In an internal build, your team owns the design assets, the theme JAR, the template changes, testing and the upgrade work for every Keycloak release. In a partner build, the partner usually plans the scope, implements the theme, writes the test cases and hands over the source, documentation and runbook, while your team supplies the brand decisions, approves the design and runs acceptance tests. Agree the split in writing. Unclear ownership of the template overrides is the most common reason a theme stops working after an upgrade.

What recurs after a Keycloak login theme goes live?

Most of the cost recurs. Each Keycloak release can change templates, message keys and the theme API, and the project plans four minor releases a year, so theme testing has to repeat on a regular cycle. Keycloak says breaking changes in a minor release will be opt-in, which lowers the risk of surprise, but your templates still need to be checked against each target version before rollout. Budget for upgrade testing, template fixes, new languages and new clients as ongoing work, not a one-time delivery.

Can a team build and maintain a Keycloak login theme alone?

A team with web front-end skills, familiarity with FreeMarker templates and access to a Keycloak test instance can build a basic theme alone, and a stylesheet-based brand is often within reach. The harder part is keeping overrides small enough that upgrades stay cheap, testing login flows across clients and locales, and handling security-relevant pages such as error and recovery screens without weakening them. If nobody on the team has done a template-based upgrade before, plan for a pilot release and a documented review step before relying on it.

What inputs do we need to provide before a theme build starts?

Start with brand assets: logo files, color values, typography rules and approved copy for each page and language. Then provide a realm and client inventory listing which realms exist, which clients sign users in, which need their own login theme and which use the default. You also need a test environment that matches your production Keycloak version and deployment, with access for the people who will sign off, and a list of the authentication flows and required actions shown to users. Missing inventory items are a frequent source of late scope changes.

What should we ask for in a quote for a Keycloak login theme?

Ask for a written scope that lists each page type, each language, each client or realm with its own theme and each template expected to be overridden, with a reason for every override. Ask which parts are one-time delivery and which are recurring, including upgrade testing against each target Keycloak release, and who performs that testing. Ask for the deliverables: source code, the packaged theme JAR, deployment steps, a test plan and handover notes. Also ask what happens if design or Keycloak version changes during the build. DeployOpen plans engagements as fixed scope with agreed deliverables and timelines, so the quote should follow from that written scope.

How DeployOpen scopes and supports a Keycloak login theme

A fixed-scope agreement is the starting point for a login theme engagement. Before work begins, the written scope should list every login-flow page that will be branded (login, registration, OTP, password reset, and any error or info pages), the languages each page must support, the clients that will receive a per-client theme, and the deliverables: the packaged theme JAR, the template and stylesheet inventory, the override documentation and the upgrade runbook. DeployOpen plans and implements the theme inside your own cloud accounts, data centers or air-gapped network, so the theme is built and tested against your Keycloak version and your reverse proxy and hostname layout. Ask for the scope to name the Keycloak release it targets, because the template set that a theme extends can change between releases.

The documentation and upgrade procedure matter as much as the theme itself. DeployOpen records which templates were overridden and why, which stylesheet rules were changed, and which overrides were avoided in favor of styling through the theme's own properties. It also writes the steps your team follows when a new Keycloak minor release arrives, including how the theme is rebuilt, redeployed and checked on the login pages. Retainer-based support can cover those upgrade cycles and the regression testing of login pages after each change. Retainers are priced separately from the initial build, so ask for the recurring scope, the response expectations and the test coverage in writing.

DeployOpen does not publish a price list. A quote follows from the written scope, so the inputs that move cost are the number of pages and templates, the number of languages, the number of clients with their own themes, and whether an upgrade retainer is included. DeployOpen is not an official partner, reseller or certified provider of Keycloak or Red Hat, and it does not issue certifications for the login experience. Ask for the scope document, the list of deliverables and the upgrade and testing terms before you compare proposals with your own team's estimate.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.