Skip to main content
The ui namespace provides components and utilities for rendering UI elements in Yazi plugins.

Layout Utilities

ui.area(name)

Get the screen area for a component.
string
required
Area name: "current", "preview", or "progress"
Rect
Rectangle representing the area

ui.hide()

Hide the UI and yield to a subprocess (async).
Permit
Permit handle - UI will show again when dropped
Cannot call ui.hide() while main thread is blocked or while already hidden.

ui.render()

Request a UI re-render.

ui.redraw(component)

Redraw a component.
table
required
Component table with redraw() method
table
Renderable elements

Text Utilities

ui.truncate(str, options)

Truncate a string to fit a maximum width.
string
required
String to truncate
table
required
Truncation options
number
required
Maximum width in characters
bool
Truncate from left (right-to-left) instead of right (default: false)
string
Truncated string with ellipsis (…) if needed

ui.width(value)

Calculate display width of a string or UI element.
string|Line|Span
required
String or UI element
number
Display width (accounting for wide characters)

ui.printable(str)

Convert non-printable characters to printable form.
string
required
String to convert
string
String with printable characters only

UI Components

All UI components support chaining methods and must have an area set.

Common Methods

All components support these methods:
  • :area(rect) - Set component area

ui.Bar(value, symbol?)

Progress bar component.
number
required
Value between 0 and 100
string
Bar symbol (default: ”█“)

ui.Border

Border component.

Methods

  • :type(type) - Border type: ui.Border.PLAIN, ui.Border.ROUNDED
  • :style(style) - Border style

ui.Clear

Clear a screen area.

ui.Constraint

Layout constraint.

ui.Gauge(ratio?)

Gauge/progress indicator.
number
Fill ratio between 0.0 and 1.0

Methods

  • :label(text) - Set label text
  • :style(style) - Set gauge style

ui.Layout

Layout container for arranging components.

Methods

  • :direction(dir) - ui.Layout.HORIZONTAL or ui.Layout.VERTICAL
  • :constraints(list) - List of constraints
  • :split(area) - Split area and return chunks

ui.Line(text?)

Single line of text/spans.
string|table
Text string or table of Spans

Methods

  • :align(align) - Set alignment: ui.Align.LEFT, ui.Align.CENTER, ui.Align.RIGHT
  • :style(style) - Set line style

ui.List(items?)

List of lines.
Line[]
List of Line components

ui.Pad

Padding container.

Methods

  • :position(edge) - Edge position: ui.Edge.TOP, ui.Edge.BOTTOM, etc.

ui.Paragraph(text?)

Multi-line text paragraph.
table
List of Lines

Methods

  • :wrap(wrap) - Wrap mode: ui.Wrap.NO, ui.Wrap.YES, ui.Wrap.TRIM
  • :align(align) - Text alignment

ui.Pos

Screen position.

ui.Rect

Rectangle area.

Methods

  • :padding(pad) - Apply padding and return inner rect

ui.Span(text?)

Styled text span.
string
Text content

Methods

  • :fg(color) - Foreground color
  • :bg(color) - Background color
  • :bold() - Bold text
  • :dim() - Dim text
  • :italic() - Italic text
  • :underline() - Underline text
  • :blink() - Blinking text
  • :reverse() - Reverse colors
  • :hidden() - Hidden text
  • :crossed() - Strikethrough text
  • :reset() - Reset all styles
  • :style(style) - Apply style object

ui.Style

Style object for components.
Supports the same methods as ui.Span.

ui.Table

Table component.

Methods

  • :widths(constraints) - Column width constraints
  • :col_spacing(n) - Spacing between columns

ui.Text(lines?)

Multi-line styled text.
string|Line[]
Text string or list of Lines

Methods

  • :wrap(wrap) - Wrap mode
  • :align(align) - Text alignment
  • :style(style) - Text style

Enums

ui.Align

  • ui.Align.LEFT
  • ui.Align.CENTER
  • ui.Align.RIGHT

ui.Wrap

  • ui.Wrap.NO - No wrapping
  • ui.Wrap.YES - Wrap at word boundaries
  • ui.Wrap.TRIM - Trim whitespace

ui.Edge

  • ui.Edge.TOP
  • ui.Edge.RIGHT
  • ui.Edge.BOTTOM
  • ui.Edge.LEFT