Skip to main content

use_focus

Function use_focus 

pub fn use_focus(a11y_id: NodeId) -> Memo<Focus>
Expand description

Reactively track the Focus state of an AccessibilityId.

fn highlighted_box() -> impl IntoElement {
    let a11y_id = use_a11y();
    let focus = use_focus(a11y_id);
    rect()
        .a11y_id(a11y_id)
        .a11y_focusable(true)
        .maybe(focus() == Focus::Keyboard, |el| {
            el.border(Border::new().fill(Color::BLUE).width(2.))
        })
}