Skip to main content

dp

Function dp 

pub fn dp(base: f32, role: TargetRole, tokens: &InputTokens) -> f32
Expand description

Raise one dimension to the floor its [TargetRole] demands.

  • [TargetRole::Target] — at least tokens.target_size, which is itself never below tokens.min_target_conformance (24 dp, WCAG 2.2 SC 2.5.8 AA).
  • [TargetRole::Grab] — at least tokens.grab_size.
  • [TargetRole::Decoration] — returned unchanged; a rule or an icon is not a target and must not grow.

The function only ever raises: a control that is already generous keeps its own size. A negative or non-finite base is returned as-is for a Decoration, and clamped up to the floor for the two interactive roles.