Getting started

# Installation

Add the gem, sync your icon libraries, include the kit.

## Add the gem

glyphs renders the SVGs that rails_icons syncs into your app.

```ruby
gem "glyphs"
```

glyphs depends on [phlex](https://www.phlex.fun) (~> 2.0) and [rails_icons](https://github.com/rails-designer/rails_icons) (>= 1.2) — rails_icons brings the sync generator and the `icons` gem, the pure-Ruby SVG renderer glyphs uses under the hood.

## Sync icon libraries

Skip this if rails_icons is already set up.

```shell
rails generate rails_icons:install --libraries=lucide heroicons
rails generate rails_icons:sync --libraries=lucide heroicons
```

The synced SVGs land in `app/assets/svg/icons/<library>/<variant>/` — that's where glyphs reads them at render time and where the `Glyphs/IconResolution` cop validates icon names at lint time.

## Include the kit

`Glyphs` is a Phlex::Kit — include it once in your component base class and every library component becomes a capitalized method:

```ruby
class ApplicationComponent < Phlex::HTML
  include Glyphs
end
```

```ruby
LucideIcon(:house, class: "size-4")
PhosphorIcon("lock", variant: :bold)
HeroIcon(:check, class: "size-5 text-success")
```

## Outside Rails

glyphs has no Rails dependency at runtime. Point the `icons` gem at your SVG tree and render away:

```ruby
Icons.configure do |config|
  config.base_path = File.expand_path(__dir__)
  config.icons_path = "svg/icons"
end

Glyphs::LucideIcon.new(:house).call # => "<svg ...>"
```