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::Surface: Base 2D grid ofCells (formerlyImage).ftxui::Cell: A single Unicode grapheme and its foreground/background style (formerlyPixel).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.flexbox(variants:hflow,vflow): A container displaying elements on row/columns and capable of wrapping on the next column/row when full.gridbox: A container displaying a grid of elements.filler: An element that will expand proportionally 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 displays 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.italic: Apply a underlinedDouble to text.inverted: Add a filter that will invert the foreground and the background colors.underlined(variants:underlinedDouble): Underline the given element.blink: The text drawn alternates in between visible and hidden.strikethrough: Apply a strikethrough to text.hyperlink: Make the rendered area clickable using a web browser. The link will be opened when the user clicks on it. This is supported only on a limited set of terminal emulators. List: https://github.com/Alhadis/OSC8-Adoption/.selectionColor(variants:selectionForegroundColor,selectionBackgroundColor,selectionStyle,selectionStyleReset): Set the color of an element when selected.
Flexibility & Sizing
flex(variants:flex_grow,flex_shrink): Make a child element to expand proportionally 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 cells below. This is useful in combination with dbox.nothing: A decoration doing absolutely nothing.Render: Display an element on a ftxui::Screen.
Scrolling & Focus
frame(variants:xframe,yframe): 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(variants:hscroll_indicator): Display a vertical scrollbar on the right. Colors follow the content.focus(variants:select,focusPosition,focusPositionRelative): Set thechildto be the one focused among its siblings.focusCursorBlock(variants:focusCursorBlockBlinking,focusCursorBar,focusCursorBarBlinking,focusCursorUnderline,focusCursorUnderlineBlinking): Same asfocus, but set the cursor shape to be a still block.
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.Dropdown: A dropdown menu.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,Container::Stacked): 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 componentchild. It is shown only whenshowreturns true.Collapsible: A collapsible component. It displays a checkbox with an arrow. Once activated, the child is displayed.Hoverable: Wrap a component. Gives the ability to know if it is hovered by the mouse.Window: A draggeable / resizeable window. To use multiple of them, they must be stacked usingContainer::Stacked({...})component;.
Animation
animation::RequestAnimationFrame: RequestAnimationFrame is a function that requests a new frame to be drawn in the next animation cycle.
Other
animation::easing::Linear: Modeled after the line y = x.animation::easing::QuadraticIn: Modeled after the parabola y = x^2.
Core Classes
(Component option/state structs like ButtonOption, MenuOption, InputOption, WindowOptions, etc. are linked directly from the functions that accept them.)
| Class | Description |
|---|---|
ftxui::App | App is a class that manages the application lifecycle. It is responsible for initializing the terminal, running the main loop, and cleaning up on exit. |
ftxui::Box | Box is a structure that represents a rectangular area in a 2D space. |
ftxui::Canvas | Canvas is a drawable buffer associated with drawing operations. |
ftxui::Cell | A Unicode character and its associated style. |
ftxui::Color | Color is a class that represents a color in the terminal user interface. |
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 | FlexboxConfig is a configuration structure that defines the layout properties for a flexbox container. |
ftxui::LinearGradient | A class representing the settings for linear-gradient color effect. |
ftxui::Loop | Loop is a class that manages the event loop for a component. |
ftxui::Mouse | A mouse event. It contains the coordinate of the mouse, the button pressed and the modifier (shift, ctrl, meta). |
ftxui::Node | Node is the base class for all elements in the DOM tree. |
ftxui::Requirement | Requirement is a structure that defines the layout requirements for a Node in the terminal user interface. |
ftxui::Screen | A rectangular grid of Cell. |
ftxui::Selection | Represents a selection in a terminal user interface. |
ftxui::Surface | A rectangular grid of Cell. |
ftxui::Table | Table is a utility to draw tables. |
ftxui::TableSelection |