Skip to main content

apply_state_borders

Function apply_state_borders 

Source
pub fn apply_state_borders(
    commands: Commands<'_, '_>,
    active: Query<'_, '_, (Entity, &Interaction, &mut Visuals, &mut StyleOverrides, Has<StateBorderHeld>, Option<&Hovered>, Option<&Focused>), Or<(With<Hovered>, With<Focused>)>>,
    idle: Query<'_, '_, (Entity, &mut Visuals, &mut StyleOverrides), (With<StateBorderHeld>, With<Interaction>, Without<Hovered>, Without<Focused>)>,
    orphaned: Query<'_, '_, (Entity, &mut Visuals, &mut StyleOverrides), (With<StateBorderHeld>, Without<Interaction>)>,
)
Expand description

Swap Visuals::border per interaction state: focused -> Interaction::focus_border, hovered -> Interaction::hover_border, idle -> whatever the element’s styles give it then. Focus wins over hover when both are active. Borders snap (no tween), matching CSS :hover / :focus border rules without a transition.