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.hyperlink: Make the rendered area clickable using a web browser. The link will be opened when the user click on it. This is supported only on a limited set of terminal emulator. List: https://github.com/Alhadis/OSC8-Adoption/.
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(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: Add a filter that will invert the foreground and the background colors.focus(variants:select,focusPosition,focusPositionRelative): Set thechildto be the one in focus globally.focusCursorBlock(variants:focusCursorBlockBlinking,focusCursorBar,focusCursorBarBlinking,focusCursorUnderline,focusCursorUnderlineBlinking): Same asfocus, but set the cursor shape to be a still block.
Other
FlexboxConfig::Set: Set the flexbox direction.FlexboxConfig::SetGap: Set the flexbox flex direction.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.Table::Render: Render the table.Table::SelectAll: Select all the table.Table::SelectCell: Select a cell of the table.Table::SelectColumn: Select a column of the table.Table::SelectColumns: Select a range of columns of the table.Table::SelectRectangle: Select a rectangle of the table.Table::SelectRow: Select a row of the table.Table::SelectRows: Select a range of rows of the table.Table::Table: Create an empty table.TableSelection::Border: Apply aborderaround the selection.TableSelection::BorderBottom: Draw some separator lines to the bottom side of the selection.TableSelection::BorderLeft: Draw some separator lines to the left side of the selection.TableSelection::BorderRight: Draw some separator lines to the right side of the selection.TableSelection::BorderTop: Draw some separator lines to the top side of the selection.TableSelection::Decorate: Apply thedecoratorto the selection. This decorate both the cells, the lines and the corners.TableSelection::DecorateAlternateColumn: Apply thedecoratorto the selection. This decorate only the lines modulomodulowith a shift ofshift.TableSelection::DecorateAlternateRow: Apply thedecoratorto the selection. This decorate only the lines modulomodulowith a shift ofshift.TableSelection::DecorateCells: Apply thedecoratorto the selection.TableSelection::DecorateCellsAlternateColumn: Apply thedecoratorto the selection. This decorate only the corners modulomodulowith a shift ofshift.TableSelection::DecorateCellsAlternateRow: Apply thedecoratorto the selection. This decorate only the corners modulomodulowith a shift ofshift.TableSelection::Separator: Draw some separator lines in the selection.TableSelection::SeparatorHorizontal: Draw some horizontal separator lines in the selection.TableSelection::SeparatorVertical: Draw some vertical separator lines in the selection.
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.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;.
Other
AnimatedColorOption::Set: A color option that can be animated. @params _inactive The color when the component is inactive. @params _active The color when the component is active. @params _duration The duration of the animation. @params _function The easing function of the animation.animation::easing::Linear: Modeled after the line y = x.animation::easing::QuadraticIn: Modeled after the parabola y = x^2.ButtonOption::Animated: Create a ButtonOption, using animated colors.ButtonOption::Ascii: Create a ButtonOption, highlighted using [] characters.ButtonOption::Border: Create a ButtonOption. The button is shown using a border, inverted when focused. This is the current default.ButtonOption::Simple: Create a ButtonOption, inverted when focused.CheckboxOption::Simple: Option for standard Checkbox.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.Event::Character: An event corresponding to a given typed character.Event::Mouse: An event corresponding to a given typed character.Event::Special: An custom event whose meaning is defined by the user of the library.InputOption::Default: Create the default input style:InputOption::Spacious: A white on black style with high margins:Loop::HasQuitted: Whether the loop has quitted.Loop::Loop: A Loop is a wrapper around a Component and a ScreenInteractive. It is used to run a Component in a terminal.MenuOption::Horizontal: Standard options for an horizontal menu. This can be useful to implement a tab bar.MenuOption::HorizontalAnimated: Standard options for an animated horizontal menu. This can be useful to implement a tab bar.MenuOption::Toggle: Standard options for a horitontal menu with some separator. This can be useful to implement a tab bar.MenuOption::Vertical: Standard options for a vertical menu. This can be useful to implement a list of selectable items.MenuOption::VerticalAnimated: Standard options for an animated vertical menu. This can be useful to implement a list of selectable items.RadioboxOption::Simple: Option for standard Radiobox.ScreenInteractive::CaptureMouse: Try to get the unique lock about behing able to capture the mouse.ScreenInteractive::Exit: Exit the main loop.ScreenInteractive::ExitLoopClosure: Return a function to exit the main loop.ScreenInteractive::HasQuitted: Return whether the main loop has been quit.ScreenInteractive::Loop: Execute the main loop.ScreenInteractive::Post: Add a task to the main loop. It will be executed later, after every other scheduled tasks.ScreenInteractive::PostEvent: Add an event to the main loop. It will be executed later, after every other scheduled events.ScreenInteractive::TrackMouse: Set whether mouse is tracked and events reported. called outside of the main loop. E.gScreenInteractive::Loop(...).UnderlineOption::SetAnimation: Set how the underline should animate.UnderlineOption::SetAnimationDuration: Set how the underline should animate.UnderlineOption::SetAnimationFunction: Set how the underline should animate.
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 |