class Line::Message::Builder::Flex::Text

Represents a text component in a LINE Flex Message.

Text components are used to display strings of text. They offer various styling options, including font size, weight (via styles in a Box or Bubble), color, +align+ment, gravity, text +wrap+ping, line_spacing, and more. A text component can also have an action to make it tappable.

Text components also support embedded Span components, which allow parts of the text to have different styling. Spans can be added to a text component using the span method within the Text component block.

Example: Creating a text component within a box

Line::Message::Builder.with do
  flex alt_text: "Text Example" do
    bubble do
      body do
        text "Hello, Flex World!",
             size: :xl,
             color: "#FF0000",
             wrap: true do
               message "More info", text: "Tell me more about text"
        end
      end
    end
  end
end

Example: Creating a text component with spans

Line::Message::Builder.with do
  flex alt_text: "Span Example" do
    bubble do
      body do
        text "This message has styled spans:" do
          span "Red", color: "#FF0000"
          span " and ", size: :sm
          span "Bold", weight: :bold
        end
      end
    end
  end
end

See also: