Project

ascona

0.0
A long-lived project that still receives updates
A Ruby gem for using SVG icons.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 1.0
 Project Readme

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:install

Or create config/initializers/ascona.rb manually:

Ascona.configure do |config|
  config.icon_path = "app/assets/icons"
  config.default_library = :lucide
end

Supported 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 variant

Folder 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 = 5

Icons 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::Helper

Call Ascona.load before using icons.

License

MIT