# Getting started

> Add Shadleaf to a Spring Boot application.

Source: https://shadleaf.dev/1.2.0/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

Add the dependency to your `pom.xml` of your Spring Boot with Thymeleaf application:

```xml
<dependency>
  <groupId>io.github.wimdeblauwe</groupId>
  <artifactId>shadleaf-spring-boot-starter</artifactId>
  <version>1.2.0</version>
</dependency>
```

> **Note: Don't have an application yet?**
>
> You can generate an application from [Spring Initializr](https://start.spring.io/) with the Spring Web & Thymeleaf dependencies.
>
> Alternatively, use [ttcli](https://github.com/wimdeblauwe/ttcli) to generate an application.
> It allows to have a very nice live-reload setup for quick development.

## Include the stylesheet and the theme script

In the `<head>` of your layout:

```html
<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>`](https://shadleaf.dev/1.2.0/components/theme-toggle.md) 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](https://shadleaf.dev/1.2.0/guides/alpine.md) if your application loads Alpine itself.

If you want to use Tailwind CSS in your own pages, see [Tailwind CSS](https://shadleaf.dev/1.2.0/guides/tailwind.md) for how to set it up.

If you have a Content-Security-Policy, see [CSP](https://shadleaf.dev/1.2.0/guides/csp.md) for more information.

## Use the components

Add a component to your Thymeleaf template:

```html
<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](https://shadleaf.dev/1.2.0/components.md) section for all available components and their attributes.

## Next steps

Build your pages:

- [Layouts](https://shadleaf.dev/1.2.0/layouts.md): whole page layouts to copy, with a sidebar or a header, as the starting point of your
  application.
- [Forms with htmx](https://shadleaf.dev/1.2.0/guides/forms-htmx.md): post a form and get it back with its errors, without a page load.
- [Tables with htmx](https://shadleaf.dev/1.2.0/guides/tables-htmx.md): search, sort and page a server-side table.
- [Error handling](https://shadleaf.dev/1.2.0/guides/error-handling.md): error pages and error toasts built from Shadleaf components.

Make it your own:

- [The adjustability ladder](https://shadleaf.dev/1.2.0/guides/adjustability.md): from a prop to a skin to owning a component's template.
- [Translating](https://shadleaf.dev/1.2.0/guides/translating.md): the components' built-in texts in your users' languages.

Fit it into your application:

- [Spring Security](https://shadleaf.dev/1.2.0/guides/spring-security.md) and [Signing in with OAuth2](https://shadleaf.dev/1.2.0/guides/oauth2.md): the signed-in user
  and the user menu.
- [Content-Security-Policy](https://shadleaf.dev/1.2.0/guides/csp.md), [htmx](https://shadleaf.dev/1.2.0/guides/htmx.md), [Tailwind CSS](https://shadleaf.dev/1.2.0/guides/tailwind.md) and
  [Alpine.js](https://shadleaf.dev/1.2.0/guides/alpine.md).
- [Configuration](https://shadleaf.dev/1.2.0/configuration.md): every `shadleaf.*` property in one table.

Work faster:

- [IDE completion](https://shadleaf.dev/1.2.0/ide-completion.md) for `sl:*` tags in IntelliJ IDEA and WebStorm.
- [Coding agents](https://shadleaf.dev/1.2.0/coding-agents.md): point Claude Code, Cursor or Copilot at these docs.
- Know shadcn/ui already? [Coming from shadcn/ui](https://shadleaf.dev/1.2.0/coming-from-shadcn.md) lists what differs.

## Is Shadleaf right for your project?

Still deciding? [Compared with other libraries](https://shadleaf.dev/1.2.0/compared.md) sets Shadleaf next to daisyUI, Flowbite, Basecoat, Vaadin
and others, and says when another one is the better choice.
