@solid-aria/focus
Version:
Primitives for dealing with focus rings and focus management.
43 lines (42 loc) • 1.47 kB
TypeScript
import { FocusResult, FocusWithinResult } from "@solid-aria/interactions";
import { MaybeAccessor } from "@solid-primitives/utils";
import { Accessor } from "solid-js";
export interface CreateFocusRingProps {
/**
* Whether to show the focus ring when something
* inside the container element has focus (true), or
* only if the container itself has focus (false).
* @default 'false'
*/
within?: MaybeAccessor<boolean | undefined>;
/**
* Whether the element is a text input.
*/
isTextInput?: MaybeAccessor<boolean | undefined>;
/**
* Whether the element will be auto focused.
*/
autofocus?: MaybeAccessor<boolean | undefined>;
}
declare type FocusRingProps = FocusResult["focusProps"] | FocusWithinResult["focusWithinProps"];
export interface FocusRingResult {
/**
* Whether the element is currently focused.
*/
isFocused: Accessor<boolean>;
/**
* Whether keyboard focus should be visible.
*/
isFocusVisible: Accessor<boolean>;
/**
* Props to apply to the container element with the focus ring.
*/
focusProps: FocusRingProps;
}
/**
* Determines whether a focus ring should be shown to indicate keyboard focus.
* Focus rings are visible only when the user is interacting with a keyboard,
* not with a mouse, touch, or other input methods.
*/
export declare function createFocusRing(props?: CreateFocusRingProps): FocusRingResult;
export {};