@yamada-ui/focus-lock
Version:
Yamada UI focus lock component
68 lines (65 loc) • 1.98 kB
TypeScript
import { FC } from '@yamada-ui/core';
import { FocusableElement } from '@yamada-ui/utils';
import { ReactNode, RefObject } from 'react';
interface FocusLockProps {
children: ReactNode;
/**
* If `true`, the first focusable element within the `children` will auto-focused once `FocusLock` mounts.
*
* @default false
*/
autoFocus?: boolean;
/**
* The `ref` of the wrapper for which the focus-lock wraps.
*/
contentRef?: RefObject<HTMLElement>;
/**
* If `true`, focus trapping will be disabled.
*
* @default false
*/
disabled?: boolean;
/**
* `ref` of the element to return focus to when `FocusLock` unmounts.
*/
finalFocusRef?: RefObject<FocusableElement>;
/**
* `ref` of the element to receive focus initially.
*/
initialFocusRef?: RefObject<FocusableElement>;
/**
* If `true`, focus trapping will be disabled.
*
* @default false
*
* @deprecated Use `disabled` instead.
*/
isDisabled?: boolean;
/**
* Enables aggressive focus capturing within iframes.
* - If `true`: keep focus in the lock, no matter where lock is active.
* - If `false`: allows focus to move outside of iframe.
*
* @default false
*/
lockFocusAcrossFrames?: boolean;
/**
* If `true`, disables text selections inside, and outside focus lock.
*
* @default false
*/
persistentFocus?: boolean;
/**
* If `true`, focus will be restored to the element that triggered the `FocusLock` once it unmounts.
*
* @default false
*/
restoreFocus?: boolean;
}
/**
* `FocusLock` is a component that improves accessibility by restricting focus within elements such as modals and dialogs, and locking the focus within that range.
*
* @see Docs https://yamada-ui.com/components/other/focus-lock
*/
declare const FocusLock: FC<FocusLockProps>;
export { FocusLock, type FocusLockProps };