Wim Deblauwe

Customizing your application with Shadleaf

December 3, 2026 · 13 min read thymeleaf spring-boot

Shadleaf 1.2.0 is out! This release is about customization. It helps you make the components look like your application, and not like every other Shadleaf application. In this post, we take an existing application and give it four very different looks.

What is new in 1.2.0

Styling hooks

Every component page in the documentation now has a Styling hooks section. It lists the CSS classes of the component and its parts, and the data- and aria- attributes that you can write your own CSS rules against. The hooks are now an API, just like the props: a minor version will not rename or remove one.

shadleaf 1.2 01
Figure 1. The Styling hooks documentation of the select component

Status colors

There are now four overridable tokens that are used by the toasts: --success, --info, --warning and --destructive. The toasts now also color their icon by default. For even more color, you can turn on rich-colors on <sl:toaster>, which colors the whole toast with those token colors.

shadleaf 1.2 02
Figure 2. The default and rich color styles of the toasts

Item component

Shadleaf 1.2.0 also has a new component called item. <sl:item> shows a row of content with media, a title, a description and actions, for things like a list of settings or notifications.

shadleaf 1.2 03
Figure 3. Some examples of the item component

See 1.2.0 release notes for all details on the release, including the new Code block and Progress components.

This blog post shows how far we can take the customization of an application built with Shadleaf.

The adjustability ladder

The Shadleaf documentation has a page called The adjustability ladder. It lists six ways to make the components your own. Each step is more powerful than the one before it, but also more work to maintain:

  1. Props, like variant="outline".

  2. Pass-through attributes and classes: every attribute that is not a prop lands on the rendered element.

  3. Token overrides: redefine CSS variables like --primary and --radius.

  4. Skin: switch to one of the nine skins with shadleaf.skin=…​.

  5. Your own CSS rules, against the styling hooks of the components.

  6. Own the template: copy the template of a component into your application.

The advice is to take the first step that solves your problem. In this post, we climb from step 3 to step 5, customizing the application a little more with each step.

The example application

My friend Siva Prasad Reddy built HelpDesk with Shadleaf. It is an application to report and follow up on maintenance issues in a gated community: a leaking pipe, a power outage, a lift that is stuck. Residents raise tickets, staff members resolve them, and administrators follow everything on an analytics dashboard.

Siva was kind enough to let me use it for this post. I took the user interface of HelpDesk and kept the tickets in memory, so you can run it without a database, message broker or AI model.

This is what it looks like with plain Shadleaf, using the default vega skin:

shadleaf customization 01 default

Clean and neutral, but it looks like every other shadcn-styled application. Let’s change that.

One application, four looks

The example application has one Spring profile per look: fern, orchard, aurora and siva. Each profile sets the name of a theme:

src/main/resources/application-fern.properties
helpdesk.theme=fern

A @ControllerAdvice puts that name in the model of every page:

src/main/java/com/wimdeblauwe/examples/shadleafcustomization/ThemeAdvice.java
@ControllerAdvice
class ThemeAdvice {

    private final @Nullable String theme;

    ThemeAdvice(@Value("${helpdesk.theme:#{null}}") @Nullable String theme) {
        this.theme = theme;
    }

    @ModelAttribute("theme")
    @Nullable String theme() {
        return theme;
    }
}

The layout loads the stylesheet of the theme after the stylesheets of Shadleaf and of the application itself:

src/main/resources/templates/layout/main.html
<head>
    ...
    <th:block th:replace="~{sl/layout :: theme-script}"></th:block>
    <th:block th:replace="~{sl/layout :: assets}"></th:block>
    <link rel="stylesheet" th:href="@{/css/application.css}">
    <link th:if="${theme}" rel="stylesheet" th:href="@{/css/themes/{theme}.css(theme=${theme})}">
</head>

The profiles are only there so you can compare the looks in one application. In your own application, you pick one look and put its CSS in your own stylesheet. Each theme below is a single CSS file that you can copy as is.

Start the application with a profile to see a theme:

./mvnw spring-boot:run -Dspring-boot.run.profiles=fern

Colored statuses

Before we start with the themes, there is one thing every theme needs. In HelpDesk, the status of a ticket is a badge, and the badge only has the variants default, secondary, outline, destructive, ghost and link. None of those says "open", "in progress" or "resolved".

This is where steps 2 and 5 of the ladder work together. First, the application template passes the ticket status through to the badge as a data-* attribute:

src/main/resources/templates/tickets/list.html
<sl:badge variant="outline" th:data-status="${t.status}" th:text="${t.status.label}">Open</sl:badge>

data-status is not a known prop of <sl:badge>, so Shadleaf passes it through to the rendered <span class="badge">.

Next, the application’s stylesheet colors each status:

src/main/resources/static/css/application.css
.badge[data-status='OPEN'] {
    background: var(--info-bg);
    border-color: var(--info-border);
    color: var(--info-text);
}
.badge[data-status='IN_PROGRESS'] {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-text);
}
.badge[data-status='RESOLVED'] {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-text);
}

The --info-bg, --info-border and --info-text tokens are new in 1.2.0. Shadleaf uses them for the rich-colored toasts, and they are just as useful for a badge. You don’t need to set them yourself, because Shadleaf calculates them from --info with the CSS color-mix() function. You can also override them if you want. A closed ticket keeps the outline badge.

The nice part is that a theme does not need to know about these calculations. It sets --info, --warning and --success, and the statuses follow.

Fern: token overrides

The first theme is Fern. It keeps the application neutral and only adds green: the primary buttons, the focus ring, the sidebar and the charts.

This is step 3 of the ladder. All components are drawn with CSS variables, the same ones that shadcn/ui uses, so a theme is a list of new values for those variables:

src/main/resources/static/css/themes/fern.css
@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&display=swap');

:root {
    --font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif; (1)
    --radius: 0.625rem;

    --background: #ffffff;
    --foreground: #17201a;
    --primary: #2e6b45;
    --primary-foreground: #f4faf5;
    --secondary: #edf3ee;
    --muted: #f2f5f2;
    --muted-foreground: #5a6a5f;
    --border: #e1e8e2;
    --ring: #6fa382;
    ...

    --success: #2e6b45; (2)
    --info: #3e8c8c;
    --warning: #a8781c;

    --chart-1: #2e6b45; (3)
    --chart-2: #6fa382;
    ...

    --sidebar: #f4f8f4; (4)
    --sidebar-primary: #2e6b45;
    --sidebar-accent: #e3ede5;
    ...
}
1 The font of the whole page. Shadleaf’s bundle uses --font-sans as the default font family.
2 The new status tokens, which color the toasts and our status badges.
3 The bars in the charts use --chart-1 to --chart-5.
4 The sidebar has its own set of tokens, so it can look different from the page.

The full file sets every token; I left out a few here to keep it short.

The result is a green application:

shadleaf customization 02 fern

Don’t forget dark mode

There is one thing to watch out for. Shadleaf puts its own token values in a CSS cascade layer. A rule outside a layer always wins over a rule inside a layer, whatever the specificity of the selectors. That is great, because it means your :root block wins without any !important.

But it also means that your :root values beat Shadleaf’s dark values. If you only set --primary in :root, dark mode keeps your light green, on a dark background.

So give every token you change a dark value as well, in a .dark block after the :root block:

src/main/resources/static/css/themes/fern.css
.dark {
    --background: #0f1511;
    --foreground: #e8efe9;
    --primary: #7bc496;
    --primary-foreground: #0d1a12;
    ...
}

The theme script of Shadleaf puts class="dark" on <html> when the user picks dark mode. Both selectors have the same specificity, so the .dark block wins because it comes later.

shadleaf customization 03 fern dark

Because the tokens have shadcn’s names, a theme from a theme builder like tweakcn can be pasted in unchanged. The colors, --radius and the fonts apply. The shadows don’t, because each Shadleaf skin has its own.

Orchard: a different skin

Tokens change colors, the radius and the font. They don’t change the shape of things: how much padding a button has, whether a field is a pill or a rectangle, how big the text in a table is. That is what a skin is for, step 4 of the ladder.

Shadleaf has nine skins. The default is vega; the others are lyra, nova, maia, mira, luma, rhea, sera and sketch. You pick one with a single property:

src/main/resources/application-orchard.properties
helpdesk.theme=orchard
shadleaf.skin=maia

maia is rounded, with generous spacing, and pill-shaped buttons and fields. That fits Orchard, a soft theme in plum and apricot.

The skin gives the shapes; the tokens give the colors. So orchard.css is again only tokens, just like Fern:

src/main/resources/static/css/themes/orchard.css
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap');

:root {
    --font-sans: 'Nunito', ui-sans-serif, system-ui, sans-serif;
    --radius: 1rem;

    --primary: #7a2f8f;
    --primary-foreground: #ffffff;
    --secondary: #fde8cf;
    --secondary-foreground: #6a3a08;
    --muted: #f6f1f9;
    --accent: #f1e4f6;
    --ring: #b57cc8;

    --success: #2fa58c;
    --info: #4c7be0;
    --warning: #f0913a;

    --sidebar: #f6f0fa;
    --sidebar-accent: #ead9f3;
    ...
}

.dark {
    --primary: #d59be6;
    --primary-foreground: #2a1033;
    ...
}

Note that the skin does not need any change in the templates. The markup is exactly the same as with vega.

The form to create a ticket shows the difference best, here with the validation errors after submitting an empty form:

shadleaf customization 04 orchard form
shadleaf customization 05 orchard tickets

Every preview in the Shadleaf documentation has a skin switch. Use it to compare the skins before you pick one.

Aurora: a few rules of your own

The third theme is Aurora. It uses a gradient from violet to teal that runs through the sidebar and the primary buttons. The content stays white.

The colors are tokens again, but the gradient is a problem. A token holds a color, and a gradient is not a color. --primary: linear-gradient(…​) does not work, because Shadleaf uses --primary as a background-color, and in places like color-mix().

This is step 5 of the ladder: your own CSS rules. Shadleaf 1.2.0 documents the styling hooks of every component: the classes and attributes that you can safely write rules against. This is the Styling hooks section of the button:

shadleaf customization 06 styling hooks

The hooks come in three groups:

  • Parts: the class of the component and of each element inside it, like .button and .button-spinner.

  • Props: the attributes that reflect a prop, like data-variant for variant.

  • States: attributes for a state, like aria-current="page" on the link of the current page.

With those, the Aurora rules are short. First, two custom properties of our own for the gradients, next to the tokens:

src/main/resources/static/css/themes/aurora.css
:root {
    ...
    --aurora-gradient: linear-gradient(135deg, #6a3fe0 0%, #3a5ae6 55%, #0b7a88 100%);
    --aurora-sidebar: linear-gradient(170deg, #2b1673 0%, #1e2f86 50%, #0a5361 100%);
}

The primary button gets the gradient:

src/main/resources/static/css/themes/aurora.css
.button:not([data-variant]) { (1)
    background-image: var(--aurora-gradient);
    color: #ffffff;
}

.button:not([data-variant]):hover {
    filter: brightness(1.1) saturate(1.1);
}
1 A prop’s attribute is absent while the prop has its default value. So :not([data-variant]) selects the default variant, and leaves the outline, ghost and other buttons alone.

The sidebar is a bit more work. With variant="inset", there are two elements that paint the sidebar background: the .sidebar-provider around the whole layout (that is the color you see around the inset page), and the .sidebar itself. Both get the gradient. With background-attachment: fixed, both gradients are positioned against the viewport, so they line up into one:

src/main/resources/static/css/themes/aurora.css
.sidebar-provider,
.sidebar {
    background-image: var(--aurora-sidebar);
    background-attachment: fixed;
}

.sidebar-menu-button[aria-current='page'] { (1)
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 18%);
}
1 A thin light edge around the current page in the menu.

The sidebar tokens make the text white, so it is readable on the dark gradient:

src/main/resources/static/css/themes/aurora.css
:root {
    ...
    --sidebar: #24185f;
    --sidebar-foreground: #ffffff;
    --sidebar-accent: rgb(255 255 255 / 16%);
    --sidebar-accent-foreground: #ffffff;
    ...
}

Finally, the cards with the numbers on the analytics page get a gradient line at the top. .kpi-grid is HelpDesk’s own class, and .card is the hook of <sl:card>:

src/main/resources/static/css/themes/aurora.css
.kpi-grid > .card {
    position: relative;
    overflow: hidden;
}

.kpi-grid > .card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background-image: var(--aurora-gradient);
}
shadleaf customization 07 aurora

Why your rule wins

Shadleaf’s own rules for the components sit in a cascade layer called components. Your rules in a normal stylesheet are not in a layer, and a rule outside a layer wins over a rule inside one, whatever the specificity.

So you don’t need long selectors or !important to beat the skin. .button:not([data-variant]) wins, also against the skin’s rules for the hover or focus state with more specific selectors.

If you do put your own rules in a cascade layer, make sure that layer comes after components in the layer order.

Siva: a whole new personality

For the last theme, I wanted to go all the way. Siva, named after the author of HelpDesk, is loud on purpose: electric blue, hot pink, lime and butter yellow, held together by thick ink outlines and hard offset shadows. I would probably not ship this to the residents of a gated community, but it shows how far you get without touching a template.

shadleaf customization 08 siva

Again, the colors are tokens. Note that --border is the ink color, so every border in the application turns dark, also the lines between the table rows:

src/main/resources/static/css/themes/siva.css
:root {
    --font-sans: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
    --radius: 0.5rem;

    --background: #fffdf5;
    --foreground: #1b1340;
    --primary: #c2185b;
    --secondary: #c8f560;
    --accent: #ffe066;
    --border: #1b1340;
    --input: #1b1340;

    --success: #c8f560;
    --info: #7cc8ff;
    --warning: #ffc43d;

    --sidebar: #2f49ff;
    --sidebar-foreground: #ffffff;
    --sidebar-accent: #ffe066;
    --sidebar-accent-foreground: #1b1340;
    ...

    --siva-ink: #1b1340; (1)
    --siva-shadow: 4px 4px 0 var(--siva-ink);
    --siva-shadow-sm: 2px 2px 0 var(--siva-ink);
}
1 Our own custom properties for the shadows. In the .dark block, --siva-ink becomes black.

The borders and shadows are rules on the hooks. The buttons get an outline and a hard shadow, and "press" into the shadow while they are held down:

src/main/resources/static/css/themes/siva.css
.button:not([data-variant='ghost'], [data-variant='link']) { (1)
    border: 2px solid var(--border);
    box-shadow: var(--siva-shadow-sm);
    font-weight: 700;
}

.button:not([data-variant='ghost'], [data-variant='link']):active {
    translate: 2px 2px;
    box-shadow: none;
}

.button[aria-current='page'] { (2)
    background: var(--accent);
    color: var(--accent-foreground);
}
1 Every button, except the ghost and link buttons, which have no background to put an outline around.
2 HelpDesk marks the selected period on the analytics page (Last 7, 30 or 90 days) with aria-current="page". This state hook turns it yellow, like the current page in the sidebar.

The cards and the inset that holds the page get the bigger shadow:

src/main/resources/static/css/themes/siva.css
.card,
.sidebar-inset {
    border: 2px solid var(--border);
    box-shadow: var(--siva-shadow);
}

The badges trade their tints for solid colors with an outline. That includes the status badges from HelpDesk’s own application.css, which only need a new background:

src/main/resources/static/css/themes/siva.css
.badge {
    border: 1.5px solid var(--border);
    font-weight: 700;
}

.badge[data-status='OPEN'] {
    background: var(--info);
}

.badge[data-status='IN_PROGRESS'] {
    background: var(--warning);
}

.badge[data-status='RESOLVED'] {
    background: var(--success);
}

And a few more for the table header, the form fields and the current page in the sidebar:

src/main/resources/static/css/themes/siva.css
.table thead th {
    background: var(--accent);
    color: var(--accent-foreground);
    border-block: 2px solid var(--border);
}

.input,
.textarea,
.native-select {
    border-width: 2px;
    background: var(--card);
}

.sidebar-menu-button[aria-current='page'] {
    outline: 2px solid var(--border);
    box-shadow: var(--siva-shadow-sm);
    font-weight: 700;
}

In dark mode, --border is a light lavender, so the outlines stay visible on the dark background, while the shadows turn black:

shadleaf customization 09 siva dark

The full siva.css has about 20 rules. None of them needed a change to a template, and every selector is one of the documented hooks, or one of HelpDesk’s own classes. Because the hooks are an API, they keep working when you upgrade to the next minor version of Shadleaf.

Not everything on the page is a hook. The charts, for example, are drawn by Recharts, and their inner SVG elements are not part of Shadleaf’s API. Style them through the tokens: the bars use --chart-1 to --chart-5.

And step 6?

We never needed the last step of the ladder: owning the template. You copy the template of a component from the jar, for example templates/sl/components/badge.html, into src/main/resources/templates/sl/components/ of your application, and your copy wins.

That gives you full control, but your copy no longer receives the fixes of new Shadleaf versions. Keep it for when the markup itself has to change, not the look.

Conclusion

We gave the same HelpDesk application four looks, each one step higher on the adjustability ladder:

  • Fern only changes tokens: colors, the radius and the font, in light and in dark.

  • Orchard adds a different skin for different shapes, with one property.

  • Aurora adds a few rules of its own, since a token cannot hold the gradient.

  • Siva builds a complete personality from the styling hooks.

None of them touched a template, and the status badges, which use the new status tokens of 1.2.0, followed every theme without a change.

A big thanks to Siva for letting me use HelpDesk for this post. Be sure to check out his YouTube channel SivaLabs for great content!

See shadleaf-customization on GitHub for the full sources. To upgrade, change the version of shadleaf-spring-boot-starter in your pom.xml to 1.2.0. The adjustability ladder in the documentation has all the details.

If you have any questions or remarks, feel free to post a comment at GitHub discussions.