Expand description
Responsive value mapping: apply different values based on breakpoint.
Responsive<T> maps Breakpoint tiers to values of any type,
with inheritance from smaller breakpoints. If no value is set for a
given breakpoint, the value from the next smaller breakpoint is used.
§Usage
ⓘ
use ftui_layout::{Responsive, Breakpoint};
let padding = Responsive::new(1) // xs: 1
.at(Breakpoint::Md, 2) // md: 2
.at(Breakpoint::Xl, 4); // xl: 4
// sm inherits from xs → 1
// lg inherits from md → 2
assert_eq!(padding.resolve(Breakpoint::Sm), &1);
assert_eq!(padding.resolve(Breakpoint::Lg), &2);§Invariants
Xsalways has a value (set vianew()).- Inheritance follows breakpoint order: a missing tier inherits from the nearest smaller tier that has a value.
resolve()never fails — it always returns a reference.- Setting a value at a tier only affects that tier and tiers that inherit from it (does not affect tiers with explicit values).
§Failure Modes
None — the type system guarantees a base value at Xs.
Structs§
- Responsive
- A breakpoint-aware value with inheritance from smaller tiers.