Utilities
The Focus Trap utility is a directive that traps focus within a specified element. This is useful for modals, dropdowns, and other components that require focus to be contained within a specific area.
Import the FocusTrap primitives from ng-primitives/focus-trap
.
import { NgpFocusTrap } from 'ng-primitives/focus-trap';
Assemble the focus-trap directives in your template.
<div ngpFocusTrap></div>
The following directives are available to import from the ng-primitives/focus-trap
package:
The NgpFocusTrap
directive traps focus within the host element.
[ngpFocusTrap]
ngpFocusTrap
Attribute | Description |
---|---|
data-focus-trap |
Applied when focus is trapped. |
Adheres to the WAI-ARIA design pattern.
Copyright © 2024 Angular Primitives