Expand description
Interactive style variants for stateful widgets. Interactive style variants for stateful widgets.
InteractiveStyle holds style overrides for different interaction states:
normal, hovered, focused, active (pressed), and disabled. When resolving
the current style, the appropriate variant is merged on top of the base
style using Style::patch.
§Migration rationale
Web CSS uses pseudo-classes (:hover, :focus, :active, :disabled)
to apply conditional styles. This module provides an equivalent
terminal-native model that the migration code emitter can target.
§Example
use ftui_style::Style;
use ftui_style::interactive::{InteractiveStyle, InteractionState};
use ftui_render::cell::PackedRgba;
let interactive = InteractiveStyle::new(
Style::new().fg(PackedRgba::WHITE).bg(PackedRgba::rgb(64, 64, 64)),
)
.hover(Style::new().bg(PackedRgba::rgb(128, 128, 128)))
.focused(Style::new().bg(PackedRgba::BLUE))
.disabled(Style::new().fg(PackedRgba::rgb(64, 64, 64)));
// Resolve for the current state
let current = interactive.resolve(InteractionState::Hovered);Structs§
- Interactive
Style - Style variants for different interaction states.
Enums§
- Interaction
State - The interaction state of a widget.