pub struct TableTheme {
pub border: Style,
pub header: Style,
pub row: Style,
pub row_alt: Style,
pub row_selected: Style,
pub row_hover: Style,
pub divider: Style,
pub padding: u8,
pub column_gap: u8,
pub row_height: u8,
pub effects: Vec<TableEffectRule>,
pub preset_id: Option<TablePresetId>,
}Expand description
Shared theme for all table render paths.
This controls base styles (border/header/rows), spacing, and optional effect rules that can animate or accent specific rows/columns.
Determinism guidance: always supply an explicit phase from the caller (e.g., tick count or frame index). Avoid implicit clocks inside themes.
§Examples
Apply a preset and add an animated row highlight:
use ftui_style::{
TableEffect, TableEffectRule, TableEffectScope, TableEffectTarget, TableSection, TableTheme,
Style,
};
use ftui_render::cell::PackedRgba;
let theme = TableTheme::aurora().with_effect(TableEffectRule::new(
TableEffectTarget::Row(0),
TableEffect::Pulse {
fg_a: PackedRgba::rgb(240, 245, 255),
fg_b: PackedRgba::rgb(255, 255, 255),
bg_a: PackedRgba::rgb(28, 36, 54),
bg_b: PackedRgba::rgb(60, 90, 140),
speed: 1.0,
phase_offset: 0.0,
},
));
let resolver = theme.effect_resolver();
let phase = 0.25; // caller-supplied (e.g., tick * 0.02)
let scope = TableEffectScope::row(TableSection::Body, 0);
let _animated = resolver.resolve(theme.row, scope, phase);Override a preset for custom header + zebra rows:
use ftui_style::{TableTheme, Style};
use ftui_render::cell::PackedRgba;
let theme = TableTheme::terminal_classic()
.with_header(Style::new().fg(PackedRgba::rgb(240, 240, 240)).bold())
.with_row_alt(Style::new().bg(PackedRgba::rgb(20, 20, 20)))
.with_divider(Style::new().fg(PackedRgba::rgb(60, 60, 60)))
.with_padding(1)
.with_column_gap(2);Fields§
§border: StyleBorder style (table outline).
header: StyleHeader row style.
row: StyleBase body row style.
row_alt: StyleAlternate row style for zebra striping.
row_selected: StyleSelected row style.
row_hover: StyleHover row style.
divider: StyleDivider/column separator style.
padding: u8Cell padding inside each column (in cells).
column_gap: u8Gap between columns (in cells).
row_height: u8Row height in terminal lines.
effects: Vec<TableEffectRule>Effect rules resolved per row/column/section.
preset_id: Option<TablePresetId>Optional preset identifier for diagnostics.
Implementations§
Source§impl TableTheme
impl TableTheme
Sourcepub const fn effect_resolver(&self) -> TableEffectResolver<'_>
pub const fn effect_resolver(&self) -> TableEffectResolver<'_>
Create a resolver that applies this theme’s effects.
Sourcepub fn preset(preset: TablePresetId) -> Self
pub fn preset(preset: TablePresetId) -> Self
Build a theme from a preset identifier.
Sourcepub fn with_border(self, border: Style) -> Self
pub fn with_border(self, border: Style) -> Self
Set the border style.
Sourcepub fn with_header(self, header: Style) -> Self
pub fn with_header(self, header: Style) -> Self
Set the header style.
Sourcepub fn with_row_alt(self, row_alt: Style) -> Self
pub fn with_row_alt(self, row_alt: Style) -> Self
Set the alternate row style.
Sourcepub fn with_row_selected(self, row_selected: Style) -> Self
pub fn with_row_selected(self, row_selected: Style) -> Self
Set the selected row style.
Sourcepub fn with_row_hover(self, row_hover: Style) -> Self
pub fn with_row_hover(self, row_hover: Style) -> Self
Set the hover row style.
Sourcepub fn with_divider(self, divider: Style) -> Self
pub fn with_divider(self, divider: Style) -> Self
Set the divider style.
Sourcepub fn with_padding(self, padding: u8) -> Self
pub fn with_padding(self, padding: u8) -> Self
Set table padding (cells inset).
Sourcepub fn with_column_gap(self, column_gap: u8) -> Self
pub fn with_column_gap(self, column_gap: u8) -> Self
Set column gap in cells.
Sourcepub fn with_row_height(self, row_height: u8) -> Self
pub fn with_row_height(self, row_height: u8) -> Self
Set row height in lines.
Sourcepub fn with_effects(self, effects: Vec<TableEffectRule>) -> Self
pub fn with_effects(self, effects: Vec<TableEffectRule>) -> Self
Replace effect rules.
Sourcepub fn with_effect(self, effect: TableEffectRule) -> Self
pub fn with_effect(self, effect: TableEffectRule) -> Self
Append a single effect rule.
Sourcepub fn clear_effects(self) -> Self
pub fn clear_effects(self) -> Self
Remove all effect rules.
Sourcepub fn with_preset_id(self, preset_id: Option<TablePresetId>) -> Self
pub fn with_preset_id(self, preset_id: Option<TablePresetId>) -> Self
Override the preset identifier (used for diagnostics).
Sourcepub fn terminal_classic() -> Self
pub fn terminal_classic() -> Self
ANSI-16 baseline with richer palettes on 256/truecolor terminals.
Sourcepub fn terminal_classic_for(profile: ColorProfile) -> Self
pub fn terminal_classic_for(profile: ColorProfile) -> Self
ANSI-16 baseline with richer palettes on 256/truecolor terminals.
Sourcepub fn diagnostics(&self) -> TableThemeDiagnostics
pub fn diagnostics(&self) -> TableThemeDiagnostics
Produce a deterministic diagnostics summary for logging or tests.
Sourcepub fn style_hash(&self) -> u64
pub fn style_hash(&self) -> u64
Stable hash of base styles + layout parameters.
Sourcepub fn effects_hash(&self) -> u64
pub fn effects_hash(&self) -> u64
Stable hash of effect rules (target + effect + blend + mask).
Trait Implementations§
Source§impl Clone for TableTheme
impl Clone for TableTheme
Source§fn clone(&self) -> TableTheme
fn clone(&self) -> TableTheme
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more