Skip to main content

TableTheme

Struct TableTheme 

Source
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: Style

Border style (table outline).

§header: Style

Header row style.

§row: Style

Base body row style.

§row_alt: Style

Alternate row style for zebra striping.

§row_selected: Style

Selected row style.

§row_hover: Style

Hover row style.

§divider: Style

Divider/column separator style.

§padding: u8

Cell padding inside each column (in cells).

§column_gap: u8

Gap between columns (in cells).

§row_height: u8

Row 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

Source

pub const fn effect_resolver(&self) -> TableEffectResolver<'_>

Create a resolver that applies this theme’s effects.

Source

pub fn preset(preset: TablePresetId) -> Self

Build a theme from a preset identifier.

Source

pub fn with_border(self, border: Style) -> Self

Set the border style.

Source

pub fn with_header(self, header: Style) -> Self

Set the header style.

Source

pub fn with_row(self, row: Style) -> Self

Set the base row style.

Source

pub fn with_row_alt(self, row_alt: Style) -> Self

Set the alternate row style.

Source

pub fn with_row_selected(self, row_selected: Style) -> Self

Set the selected row style.

Source

pub fn with_row_hover(self, row_hover: Style) -> Self

Set the hover row style.

Source

pub fn with_divider(self, divider: Style) -> Self

Set the divider style.

Source

pub fn with_padding(self, padding: u8) -> Self

Set table padding (cells inset).

Source

pub fn with_column_gap(self, column_gap: u8) -> Self

Set column gap in cells.

Source

pub fn with_row_height(self, row_height: u8) -> Self

Set row height in lines.

Source

pub fn with_effects(self, effects: Vec<TableEffectRule>) -> Self

Replace effect rules.

Source

pub fn with_effect(self, effect: TableEffectRule) -> Self

Append a single effect rule.

Source

pub fn clear_effects(self) -> Self

Remove all effect rules.

Source

pub fn with_preset_id(self, preset_id: Option<TablePresetId>) -> Self

Override the preset identifier (used for diagnostics).

Source

pub fn aurora() -> Self

Luminous header with cool zebra rows.

Source

pub fn graphite() -> Self

Monochrome, maximum legibility at dense data.

Source

pub fn neon() -> Self

Neon accent header with vivid highlights.

Source

pub fn slate() -> Self

Subtle slate tones for neutral dashboards.

Source

pub fn solar() -> Self

Warm, sunlight-forward palette.

Source

pub fn orchard() -> Self

Orchard greens with soft depth.

Source

pub fn paper() -> Self

Light, paper-like styling for documentation tables.

Source

pub fn midnight() -> Self

Deep, nocturnal palette with high contrast accents.

Source

pub fn terminal_classic() -> Self

ANSI-16 baseline with richer palettes on 256/truecolor terminals.

Source

pub fn terminal_classic_for(profile: ColorProfile) -> Self

ANSI-16 baseline with richer palettes on 256/truecolor terminals.

Source

pub fn diagnostics(&self) -> TableThemeDiagnostics

Produce a deterministic diagnostics summary for logging or tests.

Source

pub fn style_hash(&self) -> u64

Stable hash of base styles + layout parameters.

Source

pub fn effects_hash(&self) -> u64

Stable hash of effect rules (target + effect + blend + mask).

Trait Implementations§

Source§

impl Clone for TableTheme

Source§

fn clone(&self) -> TableTheme

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TableTheme

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TableTheme

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more