class Line::Message::Builder::Flex::Button
Represents a “button” component in a LINE Flex Message.
Buttons are interactive elements that users can tap to trigger an action (e.g., open a URL, send a message, or trigger a postback). They have various styling options, including style (primary, secondary, link) and height.
An action is mandatory for a button component.
Example
Line::Message::Builder.with do flex alt_text: "Button Example" do bubble do body do button style: :primary, height: :sm do message "Buy Now", label: "Buy" # Action definition end end end end end
See also:
-
Actionablefor defining the button’s action (mandatory) -
Position::Verticalforgravityproperty -
Position::Paddingfor padding properties -
Position::Marginformarginproperty -
Position::Offsetfor offset properties -
Size::Flexfor flex sizing property -
Size::AdjustModeforadjust_modeproperty
Public Class Methods
Source
# File lib/line/message/builder/flex/button.rb, line 84 def initialize(context: nil, **options, &) super # Calls Base#initialize, sets options, and evals block (which should define the action) end
Initializes a new Flex Message Button component.
The provided block is instance-eval’d, primarily used to define the button’s action using methods from the Actionable module (e.g., message).
- context
-
An optional context for the builder
- options
-
A hash of options to set instance variables (e.g.,
:style,:height, and options from included modules) - block
-
A block to define the button’s action and other properties. This block is where you should call an action method like
messageorpostback.
Line::Message::Builder::Base::new