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 bg(value: String) -> vattr.Attribute(msg)

Set the background color.

pub fn blink(value: Bool) -> vattr.Attribute(msg)

Make text blink.

pub fn bold(value: Bool) -> vattr.Attribute(msg)

Make text bold.

pub fn border_color(value: String) -> vattr.Attribute(msg)

Set the border color.

pub fn border_style(value: String) -> vattr.Attribute(msg)

Set the border style: “single”, “double”, “round”, “bold”, “none”.

pub fn bottom(value: Int) -> vattr.Attribute(msg)

Set the bottom position offset.

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 color(value: String) -> vattr.Attribute(msg)

Alias for fg (foreground color).

pub fn column_gap(value: Int) -> vattr.Attribute(msg)

Set the gap between columns.

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_color(value: String) -> vattr.Attribute(msg)

Set the cursor color.

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 dim(value: Bool) -> vattr.Attribute(msg)

Dim text.

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 fg(value: String) -> vattr.Attribute(msg)

Set the foreground (text) color.

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_grow(value: Int) -> vattr.Attribute(msg)

Set the flex grow factor.

pub fn flex_shrink(value: Int) -> vattr.Attribute(msg)

Set the flex shrink factor.

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: Int) -> vattr.Attribute(msg)

Set the gap between flex items.

pub fn gap_(value: String) -> vattr.Attribute(msg)

Set the gap between flex items using a string value (for percentages).

pub fn height(value: Int) -> vattr.Attribute(msg)

Set the height of a TUI element.

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 id(value: String) -> vattr.Attribute(msg)

Set the element id.

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 italic(value: Bool) -> vattr.Attribute(msg)

Make text italic.

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: Int) -> vattr.Attribute(msg)

Set the left position offset.

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 live(value: Bool) -> vattr.Attribute(msg)

Enable or disable live updates.

pub fn margin(value: Int) -> vattr.Attribute(msg)

Set the margin on all sides.

pub fn margin_(value: String) -> vattr.Attribute(msg)

Set the margin on all sides using a string value.

pub fn margin_bottom(value: Int) -> vattr.Attribute(msg)

Set the bottom margin.

pub fn margin_bottom_(value: String) -> vattr.Attribute(msg)

Set the bottom margin using a string value.

pub fn margin_left(value: Int) -> vattr.Attribute(msg)

Set the left margin.

pub fn margin_left_(value: String) -> vattr.Attribute(msg)

Set the left margin using a string value.

pub fn margin_right(value: Int) -> vattr.Attribute(msg)

Set the right margin.

pub fn margin_right_(value: String) -> vattr.Attribute(msg)

Set the right margin using a string value.

pub fn margin_top(value: Int) -> vattr.Attribute(msg)

Set the top margin.

pub fn margin_top_(value: String) -> vattr.Attribute(msg)

Set the top margin using a string value.

pub fn max(value: Float) -> vattr.Attribute(msg)

Set the slider maximum value.

pub fn max_height(value: Int) -> vattr.Attribute(msg)

Set the maximum height.

pub fn max_height_(value: String) -> vattr.Attribute(msg)

Set the maximum height using a string value.

pub fn max_length(value: Int) -> vattr.Attribute(msg)

Set the maximum input length.

pub fn max_width(value: Int) -> vattr.Attribute(msg)

Set the maximum width.

pub fn max_width_(value: String) -> vattr.Attribute(msg)

Set the maximum width using a string value.

pub fn min(value: Float) -> vattr.Attribute(msg)

Set the slider minimum value.

pub fn min_height(value: Int) -> vattr.Attribute(msg)

Set the minimum height.

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: Int) -> vattr.Attribute(msg)

Set the minimum width.

pub fn min_width_(value: String) -> vattr.Attribute(msg)

Set the minimum width using a string value.

pub fn opacity(value: Float) -> vattr.Attribute(msg)

Set element opacity (0.0 to 1.0).

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: Int) -> vattr.Attribute(msg)

Set the padding on all sides.

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: Int) -> vattr.Attribute(msg)

Set the left padding.

pub fn padding_left_(value: String) -> vattr.Attribute(msg)

Set the left padding using a string value.

pub fn padding_right(value: Int) -> vattr.Attribute(msg)

Set the right padding.

pub fn padding_right_(value: String) -> vattr.Attribute(msg)

Set the right padding using a string value.

pub fn padding_top(value: Int) -> vattr.Attribute(msg)

Set the top padding.

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: Int) -> vattr.Attribute(msg)

Set the right position offset.

pub fn right_(value: String) -> vattr.Attribute(msg)

Set the right position offset using a string value.

pub fn row_gap(value: Int) -> vattr.Attribute(msg)

Set the gap between rows.

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 scroll_speed(value: Int) -> vattr.Attribute(msg)

Set the scroll speed.

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_cursor(value: Bool) -> vattr.Attribute(msg)

Show or hide the cursor.

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 strikethrough(value: Bool) -> vattr.Attribute(msg)

Strikethrough text.

pub fn tab_width(value: Int) -> vattr.Attribute(msg)

Set the tab width.

pub fn text_color(value: String) -> vattr.Attribute(msg)

Set the text color (Textarea/Input).

pub fn title(value: String) -> vattr.Attribute(msg)

Set a title.

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: Int) -> vattr.Attribute(msg)

Set the top position offset.

pub fn top_(value: String) -> vattr.Attribute(msg)

Set the top position offset using a string value.

pub fn truncate(value: Bool) -> vattr.Attribute(msg)

Truncate text that overflows.

pub fn underline(value: Bool) -> vattr.Attribute(msg)

Underline text.

pub fn value(value: String) -> vattr.Attribute(msg)

Set the value of an input element.

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 visible(value: Bool) -> vattr.Attribute(msg)

Set element visibility.

pub fn width(value: Int) -> vattr.Attribute(msg)

Set the width of a TUI element.

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.

pub fn z_index(value: Int) -> vattr.Attribute(msg)

Set the z-index for layering.

Search Document