UNPKG

1.9 kBTypeScriptView Raw
1import * as React from 'react';
2export interface FocusTrapProps {
3 /**
4 * If `true`, focus is locked.
5 */
6 open: boolean;
7 /**
8 * Returns an array of ordered tabbable nodes (i.e. in tab order) within the root.
9 * For instance, you can provide the "tabbable" npm dependency.
10 * @param {HTMLElement} root
11 */
12 getTabbable?: (root: HTMLElement) => string[];
13 /**
14 * This prop extends the `open` prop.
15 * It allows to toggle the open state without having to wait for a rerender when changing the `open` prop.
16 * This prop should be memoized.
17 * It can be used to support multiple focus trap mounted at the same time.
18 * @default function defaultIsEnabled(): boolean {
19 * return true;
20 * }
21 */
22 isEnabled?: () => boolean;
23 /**
24 * A single child content element.
25 */
26 children: React.ReactElement;
27 /**
28 * If `true`, the focus trap will not automatically shift focus to itself when it opens, and
29 * replace it to the last focused element when it closes.
30 * This also works correctly with any focus trap children that have the `disableAutoFocus` prop.
31 *
32 * Generally this should never be set to `true` as it makes the focus trap less
33 * accessible to assistive technologies, like screen readers.
34 * @default false
35 */
36 disableAutoFocus?: boolean;
37 /**
38 * If `true`, the focus trap will not prevent focus from leaving the focus trap while open.
39 *
40 * Generally this should never be set to `true` as it makes the focus trap less
41 * accessible to assistive technologies, like screen readers.
42 * @default false
43 */
44 disableEnforceFocus?: boolean;
45 /**
46 * If `true`, the focus trap will not restore focus to previously focused element once
47 * focus trap is hidden or unmounted.
48 * @default false
49 */
50 disableRestoreFocus?: boolean;
51}