shiny

Values

pub const align_text: fn(String, Int, alignment.Alignment) -> String

Align text within a width using an alignment.

let s = shiny.align_text("hi", 6, shiny.right)
pub const center: alignment.Alignment

Center text alignment.

pub const clear_line: fn() -> Nil

Clear the current line.

pub const clear_screen: fn() -> Nil

Clear the terminal screen and move cursor to home.

pub const confirm: fn(String) -> Bool

Yes/No prompt, returns True on yes.

let ok = shiny.confirm("Proceed?")
pub const countdown: fn(Int) -> Nil

Animated countdown: prints remaining seconds.

shiny.countdown(3)
pub const double: box_style.BoxStyle

Double-line box style.

pub const draw_box: fn(Int, Int, Int, Int, box_style.BoxStyle) -> Nil

Draw an empty box at position.

shiny.draw_box(2, 2, 20, 5, shiny.single)
pub const draw_box_with_title: fn(
  Int,
  Int,
  Int,
  Int,
  box_style.BoxStyle,
  String,
) -> Nil

Draw a box with a centered title.

shiny.draw_box_with_title(2, 2, 24, 5, shiny.double, "Demo")
pub const draw_info_panel: fn(
  Int,
  Int,
  Int,
  Int,
  String,
  List(#(String, String)),
  box_style.BoxStyle,
) -> Nil

Convenience info panel.

pub const draw_menu_box: fn(
  Int,
  Int,
  Int,
  String,
  List(String),
  Int,
  box_style.BoxStyle,
) -> Nil

Draw a simple vertical menu; selected is the index.

shiny.draw_menu_box(2, 2, 20, "Menu", ["One", "Two"], 0, shiny.single)
pub const draw_progress_box: fn(
  Int,
  Int,
  Int,
  String,
  Int,
  Int,
  box_style.BoxStyle,
) -> Nil

Draw a progress box with a percentage bar.

shiny.draw_progress_box(2, 2, 30, "Build", 7, 10, shiny.rounded)
pub const draw_text_in_box: fn(
  Int,
  Int,
  Int,
  Int,
  box_style.BoxStyle,
  String,
  List(String),
  alignment.Alignment,
) -> Nil

Draw text inside a box with alignment.

shiny.draw_text_in_box(2, 2, 28, 6, shiny.single, "Info", ["Line 1", "Line 2"], shiny.center)
pub const fill_box: fn(Int, Int, Int, Int, String) -> Nil

Fill a rectangular area with a character.

shiny.fill_box(2, 3, 10, 2, ".")
pub const get_box_chars: fn(box_style.BoxStyle) -> #(
  String,
  String,
  String,
  String,
  String,
  String,
)

Box-drawing characters for a given style.

pub const hide_cursor: fn() -> Nil

Hide the cursor.

pub const left: alignment.Alignment

Left text alignment.

pub const loading_animation: fn(String, Int) -> Nil

Spinner animation next to a message.

shiny.loading_animation("Loading", 1200)
pub const loading_loop: fn(String, List(String), Int, Int) -> Nil

Internal loading loop used by loading_animation.

pub const move_cursor_down: fn(Int) -> Nil

Move cursor down by N lines.

pub const move_cursor_up: fn(Int) -> Nil

Move cursor up by N lines.

pub fn new() -> state.TuiState

Shiny: a tiny TUI toolkit for Gleam.

Import shiny to access the most common building blocks re-exported from submodules: types, box drawing, prompts, animations, and utils.

import shiny

pub fn main() {
  shiny.clear_screen()
  shiny.draw_box(2, 2, 20, 5, shiny.single)
}

Construct a fresh TUI state.

let state = shiny.new()
pub const overwrite_line: fn(String) -> Nil

Replace the current line with new text.

pub const overwrite_with_padding: fn(String, String) -> Nil

Overwrite a line, padding to hide old characters.

pub const print_at: fn(String, Int, Int) -> Nil

Print text at x,y (1-based).

pub const progress_bar: fn(Int, Int, Int) -> String

Build a progress bar string like “[██░░] 50%”.

let bar = shiny.progress_bar(5, 10, 10)
pub const prompt_user: fn(String) -> String

Ask the user for input; trims the result.

let name = shiny.prompt_user("Name")
pub const read_line: fn(String) -> String

Read a line with a prompt (raw, untrimmed).

pub const right: alignment.Alignment

Right text alignment.

pub const rounded: box_style.BoxStyle

Rounded-corner box style.

pub const select_option: fn(String, List(String)) -> String

Select an option by number; returns the chosen string or empty.

let choice = shiny.select_option("Pick", ["A", "B"])
pub const show_cursor: fn() -> Nil

Show the cursor.

pub const single: box_style.BoxStyle

Single-line box style.

pub const sleep: fn(Int) -> Nil

Sleep for time milliseconds.

pub const thick: box_style.BoxStyle

Thick-line box style.

pub const tui_state: fn(String, List(String)) -> state.TuiState

Shorthand for the TuiState record.

pub const typewriter_effect: fn(String, Int) -> Nil

Typewriter effect for a line of text.

shiny.typewriter_effect("Hello", 30)
Search Document