DOM events

onBlur

Runs when focus leaves an element. It propagates in React. Check whether the next focused element remains within the group before treating the group as exited. A missing relatedTarget can mean focus moved outside the document.

Formal Syntax & Structure

react syntaxreact
onBlur={handler}

Working Example

Example Snippetreact
export default function App() { return <><div onBlur={e=>{if(!e.currentTarget.contains(e.relatedTarget)) console.log('Left group');}}><input aria-label='Tool'/><button type='button'>Check</button></div><button type='button'>Outside</button></>; }
React Reference