getActiveElement
Category Elements
Gets the current active element in the DOM.
Demo
Current Active Element :
Usage
Type definitions
type GetActiveElementOptions = {
/**
* Whether to automatically cleanup the event listener or not.
*
* If set to `true`, it must run in the component initialization lifecycle.
* @default true
*/
autoCleanup?: boolean;
/**
* Whether to search for the active element inside shadow DOM or not.
* @default true
*/
searchInShadow?: boolean;
};
type GetActiveElementReturn = {
/** The current active element or `null`. */
readonly current: HTMLElement | null;
/**
* The function to cleanup the event listener.
* @note Is called automatically if `options.autoCleanup` is set to `true`.
*/
cleanup: () => void;
};
/**
* Returns the element within the DOM that currently has focus.
* @see https://svelte-librarian.github.io/sv-use/docs/core/elements/get-active-element
*/
export declare function getActiveElement(options?: GetActiveElementOptions): GetActiveElementReturn;
export {};