Class: UI::InputGroup

Inherits:
Phlex::HTML
  • Object
show all
Includes:
InputGroupBehavior
Defined in:
app/components/ui/input_group.rb

Overview

InputGroup - Phlex implementation

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

Examples:

Basic usage

render UI::InputGroup.new do
  render UI::Input.new(placeholder: "Enter text")
end

With addons

render UI::InputGroup.new do
  render UI::Addon.new(align: "inline-start") { "@" }
  render UI::Input.new(placeholder: "username")
end

Instance Method Summary collapse

Methods included from InputGroupBehavior

#input_group_classes, #input_group_html_attributes

Constructor Details

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

Returns a new instance of InputGroup.

Parameters:

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

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



23
24
25
26
# File 'app/components/ui/input_group.rb', line 23

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

Instance Method Details

#view_template(&block) ⇒ Object



28
29
30
31
32
# File 'app/components/ui/input_group.rb', line 28

def view_template(&block)
  div(**input_group_html_attributes) do
    yield if block_given?
  end
end