The project is in a healthy, maintained state
A gem that allows you to quickly import Simple Icons into your Rails project.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0

Runtime

>= 0
>= 5.0, < 9.0
 Project Readme

Simple Icons Rails Gem

Gem Version

IMPORTANT

version 0.1.x gem 'simple-icons-rails', '~> 0.1.0'
version 0.2.x gem 'simple_icons_rails', '~> 0.2.0'

version 0.2.25 support Rails 8. version 0.2.26 and above are using simple-icons-rails as using the _ was not followed through at RubyGem level. We also temporarily remove support to GPR.

In 2025 we will remove support to Rails 5 and Ruby 2.7 Versions following version 0.2.25 will support Rails 6 to 8 and Ruby 3.1 to 3.3 (or higher). If you need support for Rails version 5 use either 0.1.x or 0.2.22.

Thank you for your understanding.

Description

The Simple Icons Rails Gem is a Ruby gem designed for importing and using the icons from Simple Icons in your Rails projects. Simple Icons provides a collection of more than 2500 SVG icons for various popular brands. Number of icons currently in the library

This gem simplifies the process of rendering Simple Icons in a Rails application, allowing you to easily include the icons in your views and customize their appearance. This gem is acting as a passthrough to Simple Icons CDN. The icons are not downloaded to your Rails application. This means that when a new icon is uploaded or an existing one updated, you can access it right away without having to update this gem.

For more information about Simple Icons, please visit their website: https://simpleicons.org/. You can also explore the Simple Icons GitHub repository at https://github.com/simple-icons.

Installation

To use the Simple Icons Rails Gem, follow these steps:

  1. Add the gem to your Rails application's Gemfile:

    gem 'simple_icons_rails', '~> 0.2.0'
  2. Save the Gemfile and run the following command to install the gem:

    bundle install

That's it! The Simple Icons Rails Gem is now installed and ready to be used in your Rails application.

Usage

To render Simple Icons in your Rails views, you can utilize the simpleicons helper method provided by the gem. Here's an example of how to use it:

<%= simple_icon('[ICON SLUG]', '[COLOR]', html_options = {}) %>

Replace 'github' with the name of the specific icon you want to render. You can also customize the icon's appearance by passing additional options like width, height, class, and style. Use https://simpleicons.org/ to browse available icons.

[COLOR] is optional, and can be replaced by the hex colors or CSS keywords of the icon you want to you use. The color is defaulted to the HEX color of the icon shown in simpleicons.org website. For example:

<%= simple_icon('github') %>
<%= simple_icon('github', 'red') %>
<%= simple_icon('github', 'black', class: 'custom-class', style: 'color: red;') %>
<%= simple_icon('amazon', 'red', class: 'icon', height: '32', width: '32') %>
<%= simple_icon('github', '0cf', class: 'icon', height: '32', width: '32') %>
<%= simple_icon('simpleicons', '00ccff99', class: 'icon', height: '32', width: '32') %>

Advanced configuration

Version 0.2 and above You can add a file, simple_icons.rb in your Rails app/config/initializers folder to change the CDN. See example below for more details.

# config/initializers/simple_icons.rb
SimpleIconsRails.configure do |config|
  config.cdn_url = "https://new-cdn-url.com/"
end

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/the-pew-inc/simple-icons-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

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