API Reference
FTXUI is layered into three modules: Screen (ftxui/screen), Elements (ftxui/dom), and Components (ftxui/component).
Screen (ftxui/screen)
ftxui::Screen: A rectangular grid of styled cells rendered to the terminal.ftxui::Pixel: A single Unicode grapheme and its foreground/background style.ftxui::Color: Terminal color supporting Palette16, Palette256, and 24-bit TrueColor (RGB/HSV).ftxui::Box: Inclusive 2D bounding rectangle (x_min,x_max,y_min,y_max).
(Additional terminal & string utilities are available in the ftxui/screen module reference.)
Elements (ftxui/dom)
Text & Paragraphs
text(variants:vtext): Display a piece of UTF8 encoded unicode text.paragraph: Return a vector of ftxui::text for every word of the string. This is useful combined with ftxui::hflow.
Layout & Containers
hbox: A container displaying elements horizontally one by one.vbox: A container displaying elements vertically one by one.dbox: Stack several element on top of each other.hflow: A container displaying elements horizontally one by one.gridbox: A container displaying a grid of elements.filler: An element that will take expand proportionnally to the space left in a container.
Borders, Windows & Separators
border(variants:borderLight,borderHeavy,borderDouble,borderRounded,borderStyled,borderWith): Draw a border around the element.window: Draw window with a title and a border around the element.
Data Visualization & Drawing
gauge: Draw a high definition progress bar.graph: Draw a graph using a GraphFunction.spinner: Useful to represent the effect of time and/or events. This display an ASCII art "video".
Styling & Color
color(variants:bgcolor): Set the foreground color of an element.bold: Use a bold font, for elements with more emphasis.dim: Use a light font, for elements with less emphasis.inverted: Add a filter that will invert the foreground and the background colors.underlined: Make the underlined element to be underlined.blink: The text drawn alternates in between visible and hidden.
Flexibility & Sizing
flex(variants:flex_grow,flex_shrink): Make a child element to expand proportionnally to the space left in a container.xflex(variants:xflex_grow,xflex_shrink): Expand/Minimize if possible/needed on the X axis.yflex(variants:yflex_grow,yflex_shrink): Expand/Minimize if possible/needed on the Y axis.notflex: Make the element not flexible.size: Apply a constraint on the size of an element.
Alignment, Layering & Utilities
center(variants:hcenter,vcenter,align_right): Center an element horizontally and vertically.clear_under: Before drawingchild, clear the pixels below. This is useful in.nothing: A decoration doing absolutely nothing.Render: Display an element on a ftxui::Screen.
Scrolling & Focus
frame: Allow an element to be displayed inside a 'virtual' area. It size can be larger than its container. In this case only a smaller portion is displayed. The view is scrollable to make the focused element visible.vscroll_indicator: Add a filter that will invert the foreground and the background colors.
Other
Node::ComputeRequirement: Compute how much space an elements needs.Node::Render: Display an element on a ftxui::Screen.Node::SetBox: Assign a position and a dimension to an element for drawing.
Components (ftxui/component)
Interactive Controls
Button: Draw a button. Execute a function when clicked.Checkbox: Draw checkable element.Input: An input box for editing text.Menu: A list of text. The focused element is selected.Radiobox: A list of element, where only one can be selected.Toggle: An horizontal list of elements. The user can navigate through them.Slider: An horizontal slider.
Containers & Splits
Container::Vertical(variants:Container::Horizontal,Container::Tab): A list of components, drawn one by one vertically and navigated vertically using up/down arrow key or 'j'/'k' keys.ResizableSplitLeft,ResizableSplitRight,ResizableSplitTop,ResizableSplitBottom: An horizontal split in between two components, configurable using the mouse.
Composition & Overlays
Renderer: Return a component, usingrenderto render its interface.
Other
ComponentBase::Active: Returns if the element if the currently active child of its parent.ComponentBase::ActiveChild: Return the currently Active child.ComponentBase::Add: Add a child. @param child The child to be attached.ComponentBase::CaptureMouse: Take the CapturedMouse if available. There is only one component of them. It represents a component taking priority over others.ComponentBase::ChildAt: Access the child at indexi.ComponentBase::ChildCount: Returns the number of children.ComponentBase::Detach: Detach this child from its parent.ComponentBase::DetachAllChildren: Remove all children.ComponentBase::Focusable: Return true when the component contains focusable elements. The non focusable Components will be skipped when navigating using the keyboard.ComponentBase::Focused: Returns if the elements if focused by the user. True when the ComponentBase is focused by the user. An element is Focused when it is with all its ancestors the ActiveChild() of their parents.ComponentBase::OnEvent: Called in response to an event.ComponentBase::Parent: Return the parent ComponentBase, or nul if any.ComponentBase::Render: Draw the component. Build a ftxui::Element to be drawn on the ftxi::Screen representing this ftxui::ComponentBase.ComponentBase::SetActiveChild: Make thechildto be the "active" one.ComponentBase::TakeFocus: Configure all the ancestors to give focus to this component.
Core Classes
(Component option/state structs like ButtonOption, MenuOption, InputOption, WindowOptions, etc. are linked directly from the functions that accept them.)
| Class | Description |
|---|---|
ftxui::Box | |
ftxui::Color | A class representing terminal colors. |
ftxui::ComponentBase | It implement rendering itself as ftxui::Element. It implement keyboard navigation by responding to ftxui::Event. |
ftxui::Event | Represent an event. It can be key press event, a terminal resize, or more ... |
ftxui::Mouse | A mouse event. It contains the coordinate of the mouse, the button pressed and the modifier (shift, ctrl, meta). |
ftxui::Node | |
ftxui::Pixel | A unicode character and its associated style. |
ftxui::Requirement | |
ftxui::Screen | A rectangular grid of Pixel. |
ftxui::ScreenInteractive | |
ftxui::WideStringRef | An adapter. Own or reference a constant string. For convenience, this class convert multiple mutable string toward a shared representation. |