Method: Bootstrap4Helper::Dropdown#button
- Defined in:
- lib/bootstrap4_helper/dropdown.rb
#button(context = :primary, opts = {}) ⇒ String
Used to generate a button for the dropdown. The buttons default as just a button that opens the coresponding dropdown menu. The ‘split: true` option make the button just the arrow indicator that open the menu.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bootstrap4_helper/dropdown.rb', line 37 def (context = :primary, opts = {}) split = opts.fetch(:split, false) id = opts.fetch(:id, nil) klass = opts.fetch(:class, '') data = opts.fetch(:data, {}).merge(toggle: 'dropdown') extra = split ? 'dropdown-toggle-split' : '' content_tag( :button, id: id, type: 'button', class: "dropdown-toggle btn btn-#{context} #{klass} #{extra}", data: data, aria: { haspopup: true, expanded: false } ) do split ? content_tag(:span, 'Toggle Dropdwon', class: 'sr-only') : yield end end |