Class: Fluxbit::Form::RadioGroupButtonComponent
- Inherits:
-
FieldComponent
- Object
- FieldComponent
- Fluxbit::Form::RadioGroupButtonComponent
- Includes:
- Config::Form::RadioGroupButtonComponent
- Defined in:
- app/components/fluxbit/form/radio_group_button_component.rb
Overview
The ‘Fluxbit::Form::RadioGroupButtonComponent` is a component for rendering radio buttons styled as a button group. It provides the visual appearance of grouped buttons while maintaining radio button behavior (only one option can be selected at a time).
This component is useful for creating segmented controls, view toggles, or any interface where users need to select one option from a group with a button-like appearance.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(**props) ⇒ Fluxbit::Form::RadioGroupButtonComponent
constructor
Initializes the radio group button component with the given properties.
Constructor Details
#initialize(**props) ⇒ Fluxbit::Form::RadioGroupButtonComponent
Initializes the radio group button component with the given properties.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/components/fluxbit/form/radio_group_button_component.rb', line 28 def initialize(**props) super @props = props @name = @props.delete(:name) || "radio_group_#{fx_id}" @color = (@props.delete(:color) || "").to_sym, collection: [:colors].keys, default: @@color @size = @props.delete(:size) || @@size @pill = @props.delete(:pill), default: false @outline = @color.to_s.end_with?("_outline") @options_group = [] add class: Fluxbit::Config::Form::RadioGroupButtonComponent.styles[:group], to: @props, first_element: true end |
Instance Method Details
#call ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'app/components/fluxbit/form/radio_group_button_component.rb', line 41 def call tag.div(**@props) do @options_group.each_with_index do |option, index| concat (option, index) end end end |