0.0
The project is in a healthy, maintained state
RailsGlyphs is an essential SVG icon library built exclusively for Ruby on Rails projects!
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 6.0
 Project Readme

RailsGlyphs — The essential SVG icon library

License: MIT Ruby Issues Last Commit

RailsGlyphs is an essential SVG icon library built exclusively for Ruby on Rails projects!

Supercharge your Rails apps with beautifully crafted, production ready SVG icons that blend seamlessly into any design. RailsGlyphs makes it effortless to add scalable, customizable icons served as raw SVG files and fully cached when rendered to your views, helping you ship polished interfaces faster and with less hassle.

Elevate your Rails project’s UI with RailsGlyphs — where design meets developer productivity.

Installation

Add RailsGlyphs to your Rails application's Gemfile:

gem "railsglyphs"

Then install it by running:

bundle install

Or, add the gem directly with Bundler:

bundle add railsglyphs

If you're not using Bundler, install the gem manually:

gem install railsglyphs

Usage

To use RailsGlyphs in your Rails views, call the icon helper:

icon(style, icon_name, text = nil, size: 24, **html_options)

Parameters:

  • style — Choose either "solid" or "outline" to match your design.
  • icon_name — The SVG icon name (e.g., "x", "check", "user"). See the full icon list and names.
  • text (optional) — Text to display after the icon. Note: If provided, the text will be automatically wrapped in a <span class="icon-text">...</span> for easy styling.
  • size (optional) — Icon size in pixels (default: 24).
  • html_options (optional) — Additional HTML attributes for the <i> tag wrapper (e.g., title, class, etc.).

Examples:

# Basic usage
icon('solid', 'check')

# With text (text will be wrapped in <span class="icon-text">)
icon('outline', 'user', 'Profile')

# Custom size and HTML attributes
icon('solid', 'x', 'Close', size: 40, title: 'Close this window', class: 'text-red-500')

This will render a scalable SVG icon, optionally followed by text (wrapped in a span for styling), with your custom size and HTML attributes applied.

Adding or Customizing Icons

RailsGlyphs stores SVG icons in the assets/icons directory, organized by style (solid or outline). To add your own icons or customize the set:

  1. Add a New Icon:

    • Place your SVG file in the appropriate style folder, e.g.:
      • assets/icons/solid/my_icon.svg
      • assets/icons/outline/my_icon.svg
    • Name your SVG file using lowercase letters and underscores (e.g., user_add.svg).
  2. Override Icons in Your App:

    • By default, RailsGlyphs uses the gem’s built-in icons.

    • To use your own icons, set a custom icon base path in an initializer:

      RailsGlyphs::IconHelper.icon_base_path = Rails.root.join("app/assets/icons")
    • Place your custom SVGs in the same folder structure as above.

  3. Icon Naming:

    • The icon helper uses the filename (without .svg) as the icon name.
    • For example, icon('solid', 'user_add') will look for solid/user_add.svg.
  4. Reloading:

    • If you add or change icons while your Rails server is running, you may need to restart the server to clear the icon cache.

Contributing

Bug reports, pull requests, and enhancements are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct. It's code, lets have fun!

Code of Conduct

Everyone interacting in the railsglyphs project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

License

Copyright © 2025 Victor S. Keenan. The gem is available as open source under the terms of the LICENSE file.

Coded With Love

Coded crafted by me, Victor S. Keenan. Find me on Twitter @VictorSK or hire me to design, develop, and grow your product or service.