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(variants:paragraphAlignLeft,paragraphAlignRight,paragraphAlignCenter,paragraphAlignJustify): Return an element drawing the paragraph on multiple lines.
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.gridbox: A container displaying a grid of elements.filler: An element that will take expand proportionnally to the space left in a container.emptyElement: An element of size 0x0 drawing nothing.
Borders, Windows & Separators
border(variants:borderLight,borderDashed,borderHeavy,borderDouble,borderRounded,borderEmpty,borderStyled,borderWith): Draw a border around the element.window: Draw window with a title and a border around the element.automerge: Enable character to be automatically merged with others nearby.separator(variants:separatorLight,separatorDashed,separatorHeavy,separatorDouble,separatorEmpty,separatorStyled,separatorCharacter,separatorHSelector,separatorVSelector): Draw a vertical or horizontal separation in between two other elements.
Data Visualization & Drawing
gauge(variants:gaugeLeft,gaugeRight,gaugeUp,gaugeDown,gaugeDirection): 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".canvas: Produce an element from a Canvas, or a reference to a Canvas.
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(variants:underlinedDouble): Make the underlined element to be underlined.blink: The text drawn alternates in between visible and hidden.strikethrough: Apply a strikethrough to text.
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.focusPosition,focusPositionRelative: Used inside aframe, this force the view to be scrolled toward a a given position. The position is expressed in the numbers of cells.
Other
LinearGradient::Angle: Set the angle of the gradient.LinearGradient::LinearGradient: Build the "empty" gradient. This is often followed by calls to LinearGradient::Angle() and LinearGradient::Stop(). Example:LinearGradient::Stop: Add a color stop to the gradient.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(variants:MenuEntry): 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.ResizableSplit(variants:ResizableSplitLeft,ResizableSplitRight,ResizableSplitTop,ResizableSplitBottom): A split in between two components.
Composition & Overlays
Renderer: Return a component, usingrenderto render its interface.CatchEvent: Decorate a component, usingon_eventto catch events. This function must returns true when the event has been handled, false otherwise.Maybe: Decorate a component. It is shown only when theshowfunction returns true. @params show a function returning whether the decoratorated component should be shown.Hoverable: Wrap a component. Gives the ability to know if it is hovered by the mouse.
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, and it Focusable().ComponentBase::OnAnimation: Called in response to an animation event.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::Canvas | |
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::FlexboxConfig | |
ftxui::LinearGradient | A class representing the settings for linear-gradient color effect. |
ftxui::Loop | |
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::Table | |
ftxui::TableSelection |