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

# frozen_string_literal: true

class Components::Link < Components::Essence
  BASE = "inline-flex w-fit items-center gap-1 font-medium text-gray-900 border-b-2 hover:border-gray-900 transition-colors"
  KINDS = {
    regular: "border-transparent",
    underline: "border-gray-200"
  }

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

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

  private

  def initialize_merged_classes = merge_classes([ BASE, attributes[:class] ])
end