Skip to content

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 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.

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.

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:

Fit it into your application:

Work faster:

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.