Let's see, as an example, the different ways you have to change the backgrounds image of the login page using CSS only.
body.kcBodyClass {
background: url(./assets/background.png) no-repeat center center fixed;
}
import "./main.css";
// ...
<script lang="ts">
import "./main.css";
...
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"styles": ["src/styles.css"]
},
Replacing the image without re-building the theme
If you want to be able to "hot swipe" the image, without rebuilding the theme you have to import the image from a different location.
Place the file into /public/background.png.
Then, in your CSS code import the image with an absolute path:
body.kcBodyClass {
background: url(/background.png) no-repeat center center fixed;
}
Now if you want to replace the image directly in Keycloak you'll be able to find it at:
/opt/keycloak/themes/<name of your theme>/login/resources/dist/background.png
For a more advanced example, in the following video I show how to load different background for different page and how to create theme variant.