Project

ror_icons

0.0
The project is in a healthy, maintained state
Provides HeroIcons SVG helpers for Rails views, similar to react-icons.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 7.1

Runtime

~> 1.13
 Project Readme

Ruby on Rails Icons (ror-icons)

download

RorIcons is a Ruby on Rails gem for using SVG icons in your views, inspired by React Icons. It provides HeroIcons helpers with dynamic sizing, variants, and extra HTML attributes.

Installation

Add the gem to your Gemfile:

# For released version
gem "ror_icons", "~> 0.0.1"

# For local development
gem "ror_icons", path: "~/Desktop/ror_icons"

Then run:

bundle install

If using Rails, the gem automatically loads helpers via the Engine. No additional setup is required.

Usage

Basic Example

Render an icon in a Rails view:

<%= hero_user_icon(size: 16, class: "text-red-500") %>

Parameters

size: — Icon size in pixels (default: 24).

variant: — :solid or :outline (default: :solid).

class: — CSS classes to apply to the SVG.

Extra HTML attributes can be passed as keyword arguments.

Example:

<%= hero_user_icon(size: 20, variant: :outline, class: "text-blue-500", id: "profile-icon") %>

You can get all available icons programmatically:

RorIcons::Heroicons.icon_names
# => ["user", "academic-cap", "home", ...]

Then dynamically call icons:

icon_name = "user"
icon_html = RorIcons::Heroicons.send("hero_#{icon_name}_icon", size: 24)

Adding Custom Icons

Place SVGs in the assets/icons/// folder:

assets/
  icons/
    16/
      solid/
        user.svg
    24/
      outline/
        academic-cap.svg

The gem will automatically generate helpers for all SVG filenames.

Rails Engine

If used in Rails, RorIcons::Engine automatically includes RorIcons::Heroicons in ActionView::Base. You can call helpers in your views without additional setup.

Development

Running Tests

bundle exec rake test

Requirements

Ruby ≥ 3.2 Nokogiri ≥ 1.13

Building the Gem

gem build ror_icons.gemspec
gem push ror_icons-0.0.1.gem

Contributing

Fork the repo and create a branch for your feature.

Add icons in the correct folder structure.

Add tests if you modify code.

Submit a pull request.