agnostic/platform/opentui/attribute
TUI attribute helpers for OpenTUI. These map to @opentui/core renderable properties using Lustre’s standard attribute system.
Types
Custom border characters for box elements.
pub type BorderCharacters {
BorderCharacters(
top_left: String,
top_right: String,
bottom_left: String,
bottom_right: String,
horizontal: String,
vertical: String,
top_t: String,
bottom_t: String,
left_t: String,
right_t: String,
cross: String,
)
}
Constructors
-
BorderCharacters( top_left: String, top_right: String, bottom_left: String, bottom_right: String, horizontal: String, vertical: String, top_t: String, bottom_t: String, left_t: String, right_t: String, cross: String, )
Cursor style configuration.
pub type CursorStyle {
CursorStyle(style: String, blinking: Bool)
}
Constructors
-
CursorStyle(style: String, blinking: Bool)
A select option with name and description.
pub type SelectOption {
SelectOption(name: String, description: String)
}
Constructors
-
SelectOption(name: String, description: String)
Values
pub fn added_bg(value: String) -> vattr.Attribute(msg)
Set the background color for added lines in a diff view.
pub fn added_content_bg(value: String) -> vattr.Attribute(msg)
Set the content background for added lines in a diff view.
pub fn added_line_number_bg(
value: String,
) -> vattr.Attribute(msg)
Set the background for added line numbers in a diff view.
pub fn added_sign_color(value: String) -> vattr.Attribute(msg)
Set the sign color for added lines in a diff view.
pub fn align_items(value: String) -> vattr.Attribute(msg)
Set the alignment of items on the cross axis.
pub fn align_self(value: String) -> vattr.Attribute(msg)
Set the alignment of this element on the cross axis (overrides parent’s align-items for this element).
pub fn ascii_color(value: String) -> vattr.Attribute(msg)
Set the color for an ASCIIFont element.
pub fn ascii_text(value: String) -> vattr.Attribute(msg)
Set the text for an ASCIIFont element.
pub fn background_color(value: String) -> vattr.Attribute(msg)
Set background color for Box components.
Note: For Text components, use bg instead.
pub fn border_style(value: String) -> vattr.Attribute(msg)
Set the border style: “single”, “double”, “round”, “bold”, “none”.
pub fn bottom_(value: String) -> vattr.Attribute(msg)
Set the bottom position offset using a string value.
pub fn buffered(value: Bool) -> vattr.Attribute(msg)
Enable or disable double-buffered rendering.
pub fn column_gap_(value: String) -> vattr.Attribute(msg)
Set the gap between columns using a string value.
pub fn conceal(value: Bool) -> vattr.Attribute(msg)
Enable or disable text concealing in code/markdown.
pub fn content(value: String) -> vattr.Attribute(msg)
Set the text content of a text, code, or markdown element.
pub fn context_bg(value: String) -> vattr.Attribute(msg)
Set the background color for context lines in a diff view.
pub fn context_content_bg(value: String) -> vattr.Attribute(msg)
Set the content background for context lines in a diff view.
pub fn cursor_style(
style: String,
blinking: Bool,
) -> vattr.Attribute(msg)
Set the cursor style. Pass style name and whether it should blink.
pub fn custom_border_chars(
chars: BorderCharacters,
) -> vattr.Attribute(msg)
Set custom border characters.
pub fn description_color(value: String) -> vattr.Attribute(msg)
Set the color for item descriptions in a select list.
pub fn draw_unstyled_text(value: Bool) -> vattr.Attribute(msg)
Enable or disable drawing of unstyled text in code blocks.
pub fn enable_layout(value: Bool) -> vattr.Attribute(msg)
Enable or disable layout participation.
pub fn fast_scroll_step(value: Int) -> vattr.Attribute(msg)
Set the number of items to skip when fast-scrolling.
pub fn filetype(value: String) -> vattr.Attribute(msg)
Set the filetype (alias for language).
pub fn flex_basis(value: String) -> vattr.Attribute(msg)
Set the flex basis. Accepts “auto” or a numeric/percent string.
pub fn flex_direction(value: String) -> vattr.Attribute(msg)
Set the flex direction: “row” or “column”.
pub fn flex_wrap(value: String) -> vattr.Attribute(msg)
Set flex wrap behavior: “nowrap”, “wrap”, “wrap-reverse”.
pub fn focusable(value: Bool) -> vattr.Attribute(msg)
Make an element focusable for keyboard navigation (Tab to move between
elements via focus_next/focus_previous effects).
Note: input, textarea, select, tab_select, and scrollbox are
focusable by default. Use this attribute to make box elements focusable,
or to disable focus on normally-focusable elements with focusable(False).
pub fn focused_background_color(
value: String,
) -> vattr.Attribute(msg)
Set the background color when focused (Textarea/Input only). Note: BoxRenderable does not support this - use focused_border_color instead.
pub fn focused_border_color(
value: String,
) -> vattr.Attribute(msg)
Set the border color when the element is focused.
pub fn focused_text_color(value: String) -> vattr.Attribute(msg)
Set the text color when focused (Textarea/Input only).
pub fn font(value: String) -> vattr.Attribute(msg)
Set the font for an ASCIIFont or Select element.
pub fn gap_(value: String) -> vattr.Attribute(msg)
Set the gap between flex items using a string value (for percentages).
pub fn height_(value: String) -> vattr.Attribute(msg)
Set the height using a string value. Accepts “auto”, percentages, or numeric strings.
pub fn hidden_text(value: Bool) -> vattr.Attribute(msg)
Hide text (renders as invisible but still takes up space).
pub fn initial_value(value: String) -> vattr.Attribute(msg)
Set the initial value of a textarea element.
pub fn inverse(value: Bool) -> vattr.Attribute(msg)
Invert text foreground and background colors.
pub fn item_spacing(value: Int) -> vattr.Attribute(msg)
Set the spacing between items.
pub fn justify_content(value: String) -> vattr.Attribute(msg)
Set the alignment of items on the main axis.
pub fn language(value: String) -> vattr.Attribute(msg)
Set the programming language for syntax highlighting.
pub fn left_(value: String) -> vattr.Attribute(msg)
Set the left position offset using a string value.
pub fn line_number_bg(value: String) -> vattr.Attribute(msg)
Set the background color for line numbers.
pub fn line_number_fg(value: String) -> vattr.Attribute(msg)
Set the foreground color for line numbers.
pub fn line_number_offset(value: Int) -> vattr.Attribute(msg)
Set the line number offset.
pub fn margin_(value: String) -> vattr.Attribute(msg)
Set the margin on all sides using a string value.
pub fn margin_bottom_(value: String) -> vattr.Attribute(msg)
Set the bottom margin using a string value.
pub fn margin_left_(value: String) -> vattr.Attribute(msg)
Set the left margin using a string value.
pub fn margin_right_(value: String) -> vattr.Attribute(msg)
Set the right margin using a string value.
pub fn margin_top_(value: String) -> vattr.Attribute(msg)
Set the top margin using a string value.
pub fn max_height_(value: String) -> vattr.Attribute(msg)
Set the maximum height using a string value.
pub fn max_width_(value: String) -> vattr.Attribute(msg)
Set the maximum width using a string value.
pub fn min_height_(value: String) -> vattr.Attribute(msg)
Set the minimum height using a string value.
pub fn min_length(value: Int) -> vattr.Attribute(msg)
Set the minimum input length (input elements only). While the value is
shorter than this, submit (Enter) is rejected and no enter event fires.
Must not exceed max_length — OpenTUI throws otherwise.
pub fn min_width_(value: String) -> vattr.Attribute(msg)
Set the minimum width using a string value.
pub fn options(opts: List(SelectOption)) -> vattr.Attribute(msg)
Set select options. Each option is a tuple of (name, description).
pub fn orientation(value: String) -> vattr.Attribute(msg)
Set the slider orientation: “horizontal” or “vertical”.
pub fn overflow(value: String) -> vattr.Attribute(msg)
Set overflow behavior: “hidden”, “scroll”, “visible”.
pub fn padding_(value: String) -> vattr.Attribute(msg)
Set the padding on all sides using a string value.
pub fn padding_bottom(value: Int) -> vattr.Attribute(msg)
Set the bottom padding.
pub fn padding_bottom_(value: String) -> vattr.Attribute(msg)
Set the bottom padding using a string value.
pub fn padding_left_(value: String) -> vattr.Attribute(msg)
Set the left padding using a string value.
pub fn padding_right_(value: String) -> vattr.Attribute(msg)
Set the right padding using a string value.
pub fn padding_top_(value: String) -> vattr.Attribute(msg)
Set the top padding using a string value.
pub fn placeholder(value: String) -> vattr.Attribute(msg)
Set placeholder text for inputs.
pub fn placeholder_color(value: String) -> vattr.Attribute(msg)
Set the placeholder text color.
pub fn position(value: String) -> vattr.Attribute(msg)
Set the position type: “relative” or “absolute”.
pub fn removed_bg(value: String) -> vattr.Attribute(msg)
Set the background color for removed lines in a diff view.
pub fn removed_content_bg(value: String) -> vattr.Attribute(msg)
Set the content background for removed lines in a diff view.
pub fn removed_line_number_bg(
value: String,
) -> vattr.Attribute(msg)
Set the background for removed line numbers in a diff view.
pub fn removed_sign_color(value: String) -> vattr.Attribute(msg)
Set the sign color for removed lines in a diff view.
pub fn right_(value: String) -> vattr.Attribute(msg)
Set the right position offset using a string value.
pub fn row_gap_(value: String) -> vattr.Attribute(msg)
Set the gap between rows using a string value.
pub fn scroll_margin(value: Float) -> vattr.Attribute(msg)
Set the editor’s caret-follow scroll margin as a fraction of the editor’s own viewport (e.g. 0.2 means the editor scrolls once the caret comes within 20% of the top/bottom edge). Out-of-range values are clamped by OpenTUI.
Only applicable to textarea and input elements. This tunes the
intra-editor caret follow — it is unrelated to scrollbox scrolling.
pub fn selectable(value: Bool) -> vattr.Attribute(msg)
Enable or disable text selection.
pub fn selected_background_color(
value: String,
) -> vattr.Attribute(msg)
Set the background color for the selected item in a select list.
pub fn selected_description_color(
value: String,
) -> vattr.Attribute(msg)
Set the description color for the selected item in a select list.
pub fn selected_index(value: Int) -> vattr.Attribute(msg)
Set the currently selected index.
pub fn selected_text_color(value: String) -> vattr.Attribute(msg)
Set the text color for the selected item in a select list.
pub fn selection_bg(value: String) -> vattr.Attribute(msg)
Set the selection background color.
pub fn selection_fg(value: String) -> vattr.Attribute(msg)
Set the selection foreground color.
pub fn should_fill(value: Bool) -> vattr.Attribute(msg)
Fill the box with the background color.
pub fn show_description(value: Bool) -> vattr.Attribute(msg)
Show or hide item descriptions.
pub fn show_line_numbers(value: Bool) -> vattr.Attribute(msg)
Show or hide line numbers.
pub fn show_scroll_arrows(value: Bool) -> vattr.Attribute(msg)
Show or hide scroll arrows.
pub fn show_scroll_indicator(value: Bool) -> vattr.Attribute(msg)
Show or hide the scroll indicator.
pub fn show_underline(value: Bool) -> vattr.Attribute(msg)
Show or hide the underline.
pub fn slider_value(value: Float) -> vattr.Attribute(msg)
Set the slider value (property-based, accepts Float).
pub fn sticky_scroll(value: Bool) -> vattr.Attribute(msg)
Enable or disable sticky scroll behavior.
pub fn sticky_start(value: String) -> vattr.Attribute(msg)
Set the sticky start direction: “bottom”, “top”, “left”, “right”.
pub fn streaming(value: Bool) -> vattr.Attribute(msg)
Enable or disable streaming mode for code/markdown.
pub fn text_color(value: String) -> vattr.Attribute(msg)
Set the text color (Textarea/Input).
pub fn title_alignment(value: String) -> vattr.Attribute(msg)
Set the title alignment: “left”, “center”, “right”.
pub fn title_color(value: String) -> vattr.Attribute(msg)
Set the box title color. Falls back to the border color when unset.
pub fn top_(value: String) -> vattr.Attribute(msg)
Set the top position offset using a string value.
pub fn view(value: String) -> vattr.Attribute(msg)
Set the diff view mode: “unified” or “split”.
pub fn view_port_size(value: Float) -> vattr.Attribute(msg)
Set the slider viewport size (for scrollbar-style sliders).
pub fn viewport_culling(value: Bool) -> vattr.Attribute(msg)
Enable or disable viewport culling for scrollbox performance.
pub fn width_(value: String) -> vattr.Attribute(msg)
Set the width using a string value. Accepts “auto”, percentages like “50%”, or numeric strings like “42”.
pub fn wrap_mode(value: String) -> vattr.Attribute(msg)
Set the text wrap mode: “none”, “char”, “word”.
pub fn wrap_selection(value: Bool) -> vattr.Attribute(msg)
Enable or disable wrapping at the ends of the selection list.