Menu

Link

render Link.new(href: "#") { "Read more" }

Installation

Add the component to your project

CLI

Run the following command in your terminal

bundle exec essence add link
Manually

Copy and paste the following code into your project

components/link.rb
# frozen_string_literal: true

class Components::Link < Components::Essence
  attr_reader :kind

  def initialize(kind: :regular, **attributes)
    @kind = kind
    super(**attributes)
  end

  def view_template(&)
    a(**attributes, &)
  end

  private

  def component_classes
    {
      _: {
        _: "inline-flex w-fit items-center gap-1 font-medium text-gray-900 border-b-2 hover:border-gray-900 transition-colors",
        kind: {
          regular: "border-transparent",
          underline: "border-gray-200"
        }
      }
    }.freeze
  end
end