Bundling Resources
Weave comes bundled with several frontend resources to make building web applications easier. These resources are served from the classpath and are available to your application without any additional configuration.
Bundled Resources
Tailwind CSS
Tailwind CSS v3.4.16 is included by default. It provides a utility-first CSS framework. You can use Tailwind classes directly in your Hiccup markup:
[:div.flex.items-center.justify-between.p-4.bg-white.shadow
[:h1.text-xl.font-bold "My Application"]
[:button.px-4.py-2.bg-blue-500.text-white.rounded.hover:bg-blue-600
"Click Me"]]
Tailwind is enabled by default, but you can disable it if you prefer to use your own CSS framework:
Datastar
Datastar v1.0.0-RC.5 is included for client-side reactivity and event handling. Weave uses Datastar internally for its event system and server-sent events (SSE) communication.
Squint
Squint v0.9.182 is included for JavaScript interoperability, allowing you to write Clojure code that gets transpiled to JavaScript for client-side execution.
Heroicons
Weave includes Heroicons as an SVG sprite,
making it easy to use these popular icons in your application. The
icons are accessible through the ::icon component in the
weave.components namespace:
(ns your-app.core
(:require [weave.components :as c]))
(defn view []
[:div
[::c/icon#solid-home {:class "h-6 w-6 text-blue-500"}]
[::c/icon#solid-user {:class "h-6 w-6 text-green-500"}]
[::c/icon#solid-cog {:class "h-6 w-6 text-gray-500"}]])
The icon ID format is #[style]-[name] where:
styleis eithersolidoroutlinenameis the icon name from Heroicons (e.g.,home,user,cog)
You can customize the size and color of icons using Tailwind classes.
Serving Custom Resources
You can serve your own static resources by placing them in the
resources/public directory of your project. Files in this directory
will be automatically served at the root path of your application.
For example:
your-project/
├── resources/
│ └── public/
│ ├── css/
│ │ └── custom.css
│ ├── js/
│ │ └── app.js
│ └── images/
│ └── logo.png
These files would be accessible at:
http://localhost:8080/css/custom.csshttp://localhost:8080/js/app.jshttp://localhost:8080/images/logo.png
Using Custom Resources
To use your custom resources in your application: