UNPKG

c15t

Version:

Headless JavaScript consent management platform for cookie banners, privacy preferences, consent storage, and script gating.

21 lines (16 loc) 791 B
--- title: Use Focus Trap description: Reference page for use focus trap. group: reference --- ## Parameters |Parameter|Type|Description| |--|--|--| |`shouldTrap`|`boolean`|Whether focus should be trapped| |`containerRef`|`RefObject<HTMLElement \|null> \|null`|Ref to the container element| ## Behavior * **Tab**: Moves focus to the next focusable element. Wraps to the first element when reaching the end. * **Shift+Tab**: Moves focus to the previous focusable element. Wraps to the last element when reaching the start. * Focus is restored to the previously focused element when the trap is deactivated. > ℹ️ **Info:** > ConsentBanner and ConsentDialog use useFocusTrap internally when trapFocus is enabled (default: true). You only need this hook when building custom consent UI.