class RatatuiRuby::Widgets::Center

Centers content within available space.

Layouts often require alignment. Manually calculating offsets for centering is error-prone and brittle.

This widget handles the math. It centers a child widget within the current area, resizing the child according to optional percentage modifiers.

Use it to position modals, splash screens, or floating dialogue boxes.

Examples

# Center a paragraph using 50% of width and height
Center.new(
  child: Paragraph.new(text: "Hello"),
  width_percent: 50,
  height_percent: 50
)