Ascona
Use SVG icons in Ruby.
Ascona loads your SVG icons into memory at boot. Fast lookups, simple helper.
Installation
gem 'ascona'Then bundle install.
Setup
Generate the initializer:
rails generate ascona:installOr create config/initializers/ascona.rb manually:
Ascona.configure do |config|
config.icon_path = "app/assets/icons"
config.default_library = :lucide
endSupported Libraries
| Library | Link |
|---|---|
| Lucide | lucide.dev |
Downloading Icons
ascona list # Show available libraries
ascona download lucide # Download all icons
ascona download heroicons --variant=outline # Download specific variantFolder Structure
Each SVG library should be stored in separate folders (create custom libraries by adding a new folder):
app/assets/icons/
lucide/
star.svg
arrow-left.svg
heroicons/
outline/
check.svg
solid/
check.svg
The name of the folder will be used as the library name.
Usage
<%= icon "star" %>
<%= icon "star", size: 5 %>
<%= icon "star", class: "w-5 h-5" %>
<%= icon "star", library: :heroicons, variant: :outline %>The size option adds Tailwind classes w-{size} h-{size}.
Default Size
Set a default size for all icons:
config.default_size = 5Icons without an explicit size will use this default.
Variants
Some libraries have variants. Set defaults per library (for rendering only):
config.default_variants = { heroicons: :outline }Note: Some libraries have no default variant. You must specify one when downloading (--variant=outline) and when rendering (variant: :outline) unless set in config.
Non-Rails
Include the helper manually:
include Ascona::HelperCall Ascona.load before using icons.
License
MIT