Class: BetterUi::Forms::TextInputComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- BaseComponent
- BetterUi::Forms::TextInputComponent
- Defined in:
- app/components/better_ui/forms/text_input_component.rb
Overview
A text input component with support for labels, hints, errors, and prefix/suffix icons.
This component extends BaseComponent to provide a standard text input field with optional decorative or functional icons positioned before (prefix) or after (suffix) the input text. Perfect for search fields, email inputs, URL fields, and more.
Direct Known Subclasses
Constant Summary collapse
- TYPES =
Available input types for text-based inputs. Password has its own component (PasswordInputComponent) with a Stimulus controller. Number has its own component (NumberInputComponent).
i[text email tel date time].freeze
Constants inherited from BaseComponent
Constants inherited from ApplicationComponent
ApplicationComponent::SHADOWS, ApplicationComponent::VARIANTS, ApplicationComponent::VARIANT_BODY_DIVIDE, ApplicationComponent::VARIANT_DIVIDE, ApplicationComponent::VARIANT_HEADER_BG, ApplicationComponent::VARIANT_HEADER_TEXT, ApplicationComponent::VARIANT_HIGHLIGHTED, ApplicationComponent::VARIANT_HOVERABLE, ApplicationComponent::VARIANT_RING, ApplicationComponent::VARIANT_SORT_ICON, ApplicationComponent::VARIANT_STRIPED
Instance Method Summary collapse
-
#initialize(name:, type: :text, value: nil, label: nil, hint: nil, placeholder: nil, size: :md, disabled: false, readonly: false, required: false, errors: nil, container_classes: nil, label_classes: nil, input_classes: nil, hint_classes: nil, error_classes: nil, **options) ⇒ TextInputComponent
constructor
Initializes a new text input component.
-
#with_prefix_icon ⇒ Object
Slot for rendering an icon or content before (left of) the input text.
-
#with_suffix_icon ⇒ Object
Slot for rendering an icon or content after (right of) the input text.
Methods inherited from BaseComponent
Constructor Details
#initialize(name:, type: :text, value: nil, label: nil, hint: nil, placeholder: nil, size: :md, disabled: false, readonly: false, required: false, errors: nil, container_classes: nil, label_classes: nil, input_classes: nil, hint_classes: nil, error_classes: nil, **options) ⇒ TextInputComponent
Initializes a new text input component.
All parameters are passed to BaseComponent#initialize. See the parent class for detailed parameter descriptions.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'app/components/better_ui/forms/text_input_component.rb', line 103 def initialize( name:, type: :text, value: nil, label: nil, hint: nil, placeholder: nil, size: :md, disabled: false, readonly: false, required: false, errors: nil, container_classes: nil, label_classes: nil, input_classes: nil, hint_classes: nil, error_classes: nil, ** ) @type = validate_type(type) super( name: name, value: value, label: label, hint: hint, placeholder: placeholder, size: size, disabled: disabled, readonly: readonly, required: required, errors: errors, container_classes: container_classes, label_classes: label_classes, input_classes: input_classes, hint_classes: hint_classes, error_classes: error_classes, ** ) end |
Instance Method Details
#with_prefix_icon ⇒ Object
Slot for rendering an icon or content before (left of) the input text. The icon is positioned absolutely and input padding is adjusted automatically.
85 |
# File 'app/components/better_ui/forms/text_input_component.rb', line 85 renders_one :prefix_icon |
#with_suffix_icon ⇒ Object
Slot for rendering an icon or content after (right of) the input text. The icon is positioned absolutely and input padding is adjusted automatically.
91 |
# File 'app/components/better_ui/forms/text_input_component.rb', line 91 renders_one :suffix_icon |