In the demos below, you'll be able to tell that a focus trap is active because it will turn pink. You should also be able to tell because it will trap your focus!
When a trap is active, you can deactivate it by pushing its deactivate button or, if the demo allows, hitting Escape.
When this focus trap activates, focus jumps to a specific, manually specified element.
Also, in this demo the Escape key does not deactivate the focus trap. You must click the button.
When a click outside is registered, the focus-trap will be deactivated.
A callback function can be used to determine whether or not you should be allowed to click outside of the focus trap when it's deactivated.