Class: UI::InputGroupInput

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

Overview

Input - Phlex implementation

An input element styled for use within input groups. Uses both InputBehavior and InputGroupInputBehavior for styling.

Examples:

Basic input

render UI::Input.new(
  placeholder: "Enter text",
  name: "username"
)

With type

render UI::Input.new(
  type: "email",
  placeholder: "[email protected]"
)

Instance Method Summary collapse

Methods included from InputGroupInputBehavior

#input_group_input_attributes, #input_group_input_classes, #input_group_input_html_attributes

Constructor Details

#initialize(type: "text", placeholder: nil, value: nil, name: nil, id: nil, classes: "", **attributes) ⇒ InputGroupInput

Returns a new instance of InputGroupInput.

Parameters:

  • type (String) (defaults to: "text")

    Input type (default: “text”)

  • placeholder (String) (defaults to: nil)

    Placeholder text

  • value (String) (defaults to: nil)

    Input value

  • name (String) (defaults to: nil)

    Input name attribute

  • id (String) (defaults to: nil)

    Input id attribute

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

    Additional CSS classes to merge

  • attributes (Hash)

    Additional HTML attributes



29
30
31
32
33
34
35
36
37
# File 'app/components/ui/input_group_input.rb', line 29

def initialize(type: "text", placeholder: nil, value: nil, name: nil, id: nil, classes: "", **attributes)
  @type = type
  @placeholder = placeholder
  @value = value
  @name = name
  @id = id
  @classes = classes
  @attributes = attributes
end

Instance Method Details

#view_templateObject



39
40
41
42
# File 'app/components/ui/input_group_input.rb', line 39

def view_template
  # Render the base Input component with InputGroup classes and attributes
  render UI::Input.new(**input_group_input_attributes)
end