Class: UI::InputGroupComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
InputGroupBehavior
Defined in:
app/view_components/ui/input_group_component.rb

Overview

InputGroupComponent - ViewComponent implementation

A wrapper component for grouping inputs with addons, buttons, and text. Uses InputGroupBehavior concern for shared styling logic.

Examples:

Basic usage

<%= render UI::InputGroupComponent.new do %>
  <%= render UI::InputGroupInputComponent.new(placeholder: "Enter text") %>
<% end %>

With addons

<%= render UI::InputGroupComponent.new do %>
  <%= render UI::InputGroupAddonComponent.new(align: "inline-start") do %>
    @
  <% end %>
  <%= render UI::InputGroupInputComponent.new(placeholder: "username") %>
<% end %>

Instance Method Summary collapse

Methods included from InputGroupBehavior

#input_group_classes, #input_group_html_attributes

Constructor Details

#initialize(classes: "", **attributes) ⇒ InputGroupComponent

Returns a new instance of InputGroupComponent.

Parameters:

  • classes (String) (defaults to: "")

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



25
26
27
28
# File 'app/view_components/ui/input_group_component.rb', line 25

def initialize(classes: "", **attributes)
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#callObject



30
31
32
33
34
# File 'app/view_components/ui/input_group_component.rb', line 30

def call
   :div, **input_group_html_attributes do
    content
  end
end