SVG icon component for cljfx applications.
A simple, declarative SVG component for cljfx, powered by fxsvgimage.
{:fx/type svg/icon} - no registration requiredNote: This library depends on fxsvgimage, which is only available via JitPack. You must add JitPack to your repository configuration.
{:mvn/repos {"jitpack" {:url "https://jitpack.io"}}
:deps {cljfx/cljfx {:mvn/version "1.10.6"}
org.clojars.zubad/cljfx-svg {:mvn/version "0.1.0"}}}
:repositories [["jitpack" "https://jitpack.io"]]
:dependencies [[cljfx "1.10.6"]
[org.clojars.zubad/cljfx-svg "0.1.0"]]
(ns my-app.core
(:require [cljfx.api :as fx]
[cljfx-svg.core :as svg]))
;; Use svg/icon as a function component (no registration needed)
{:fx/type :button
:graphic {:fx/type svg/icon
:src "icons/gear.svg"
:size 24}}
;; With color override
{:fx/type :label
:graphic {:fx/type svg/icon
:src "icons/heart.svg"
:size 16
:color :red}}
;; Load from classpath resources or file paths
{:fx/type svg/icon
:src "icons/star.svg" ; classpath resource
:size 20}
{:fx/type svg/icon
:src "C:/path/to/icon.svg" ; absolute file path
:size 24}
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
:src | string | Yes | - | Path to SVG file (classpath resource or file path) |
:size | number | No | - | Target width in pixels (aspect ratio preserved) |
:color | any | No | nil | Fill color override (keyword, string, or Paint) |
The :color prop accepts:
:red, :blue, :transparent"#ff0000", "rgb(255,0,0)", "red"Color/RED, (Color/rgb 255 0 0)See examples/toolbar_demo.clj for a complete working example.
Powered by fxsvgimage, this library supports:
For complete documentation, see the fxsvgimage documentation.
clj -T:build jar
clj -T:build deploy
MIT License
Copyright (c) 2024
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |