Component for rendering formatted tables with advanced layout.
Supports tables with:
- Optional headers separated from rows
- Per-cell, per-row, or per-column formatting
- Per-cell and full-table alignment
- Colors and effects
- Customizable borders (normal, rounded, double, none, custom)
- Configurable padding
- Border formatting (color, effects)
- Full-table alignment (left, center, right)
Options
Data
:headers— List of headers (if not included in data):rows— List of rows (if not included in data)
Header Formatting
:headers_color— Header color (atom, hex, or list per column):headers_effects— Header effects (list, or list of lists per column):headers_align— Header alignment (:left, :center, :right, or list)
Row Formatting
:rows_color— Row color (atom, hex, or list per column):rows_effects— Row effects (list, or list of lists per column):rows_align— Row alignment (:left, :center, :right, or list)
Specific Row Formatting
:rows_0_color— Row 0 color (atom, hex, or list per column):rows_0_effects— Row 0 effects:rows_0_align— Row 0 alignment (:left, :center, :right, or list)- (Repeat for rows1, rows2, etc.)
Border Formatting
:border_color— Border color:border_effects— Border effects
Table Style
:table_border— Border style (:normal, :rounded, :double, :none, :custom):table_border_custom— Map with custom border characters:padding— Inner cell padding (default: 1):table_align— Full table alignment (:left, :center, :right)
Examples
# Headers separated from rows
Alaja.Components.Table.print(
headers: ["ID", "Name", "Email"],
rows: [
["1", "Jake", "jake@nypd.com"],
["2", "Rosa", "rosa@nypd.com"]
],
headers_color: :cyan,
headers_effects: [:bold],
rows_color: :white,
table_border: :rounded,
padding: 1
)
# Per-column formatting
Alaja.Components.Table.print(
headers: ["Name", "Age", "City"],
rows: [["Jake", "35", "NYC"]],
headers_color: [:cyan, :yellow, :magenta],
headers_align: [:center, :right, :left]
)
# Specific row formatting
Alaja.Components.Table.print(
headers: ["Service", "Status"],
rows: [["td-ai", "OK"], ["td-auth", "ERROR"]],
rows_0_color: [:white, :green],
rows_1_color: [:white, :red]
)
# Without headers
Alaja.Components.Table.print(
rows: [
["1", "Jake", "jake@nypd.com"],
["2", "Rosa", "rosa@nypd.com"]
],
table_border: :double
)
# Border formatting
Alaja.Components.Table.print(
headers: ["ID", "Name"],
rows: [["1", "Jake"]],
border_color: :cyan,
border_effects: [:bold]
)
# Table centered in terminal
Alaja.Components.Table.print(
headers: ["A", "B"],
rows: [["1", "2"]],
table_align: :center,
table_border: :rounded
)
Summary
Types
Functions
Prints a table to the terminal.
If :page_size is set, enables interactive pagination:
n/→— next pagep/←— previous pageg— go to page (prompts for number)f/l— first / last pageq/Esc— quit
Renders a table to iodata without printing.