Menu

Text

Hello, world!

render Components::Text.new(size: :md) { "Hello, world!" }

Installation

Add the component to your project

CLI

Run the following command in your terminal

bundle exec essence add text
Manually

Copy and paste the following code into your project

components/text.rb
# frozen_string_literal: true

class Components::Text < Components::Essence
  attr_reader :size

  def initialize(size: :md, **attributes)
    @size = size
    super(**attributes)
  end

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

  private

  def component_classes
    {
      _: {
        _: "text-base text-gray-600",
        size: {
          sm: "text-sm",
          md: "text-base",
          lg: "text-lg"
        }
      }
    }.freeze
  end
end

Reference

This is how you can use this component

Attribute

Description

size
Text size
Available values —
smmdlg