Getting started
Shadleaf needs Java 17, Spring Boot 4 and Thymeleaf. The jar ships compiled CSS and JavaScript, so a plain Maven build is enough to get started.
Add the dependency
Section titled “Add the dependency”Add the dependency to your pom.xml of your Spring Boot with Thymeleaf application:
<dependency> <groupId>io.github.wimdeblauwe</groupId> <artifactId>shadleaf-spring-boot-starter</artifactId> <version>1.2.0</version></dependency>Include the stylesheet and the theme script
Section titled “Include the stylesheet and the theme script”In the <head> of your layout:
<head> <th:block th:replace="~{sl/layout :: theme-script}"></th:block> <th:block th:replace="~{sl/layout :: assets}"></th:block> <!-- your own stylesheet after it, so your overrides win --> <link rel="stylesheet" th:href="@{/css/application.css}"></head>The theme-script reads the user’s preference from localStorage and sets the class="dark" on <html> before the first paint.
Place the <sl:theme-toggle> on your page to let the user choose between light and dark mode.
The assets block renders the CSS and JS links.
By default, Alpine.js is loaded and you can use it in your own pages.
See Alpine.js if your application loads Alpine itself.
If you want to use Tailwind CSS in your own pages, see Tailwind CSS for how to set it up.
If you have a Content-Security-Policy, see CSP for more information.
Use the components
Section titled “Use the components”Add a component to your Thymeleaf template:
<html xmlns:th="http://www.thymeleaf.org" xmlns:sl="https://shadleaf.dev/sl">...<sl:button variant="outline">Cancel</sl:button><sl:button type="submit">Save</sl:button>See the Components section for all available components and their attributes.
Next steps
Section titled “Next steps”Build your pages:
- Layouts: whole page layouts to copy, with a sidebar or a header, as the starting point of your application.
- Forms with htmx: post a form and get it back with its errors, without a page load.
- Tables with htmx: search, sort and page a server-side table.
- Error handling: error pages and error toasts built from Shadleaf components.
Make it your own:
- The adjustability ladder: from a prop to a skin to owning a component’s template.
- Translating: the components’ built-in texts in your users’ languages.
Fit it into your application:
- Spring Security and Signing in with OAuth2: the signed-in user and the user menu.
- Content-Security-Policy, htmx, Tailwind CSS and Alpine.js.
- Configuration: every
shadleaf.*property in one table.
Work faster:
- IDE completion for
sl:*tags in IntelliJ IDEA and WebStorm. - Coding agents: point Claude Code, Cursor or Copilot at these docs.
- Know shadcn/ui already? Coming from shadcn/ui lists what differs.
Is Shadleaf right for your project?
Section titled “Is Shadleaf right for your project?”Still deciding? Compared with other libraries sets Shadleaf next to daisyUI, Flowbite, Basecoat, Vaadin and others, and says when another one is the better choice.