@humanspeak/svelte-motion
Version:
Framer Motion for Svelte 5. Declarative motion.<tag> components with AnimatePresence exit animations, gestures (hover, tap, drag, focus, in-view), variants, FLIP layout animations, shared-layout transitions, spring physics, and scroll-linked motion values
23 lines (22 loc) • 1.05 kB
TypeScript
import type { SvelteHTMLElements } from 'svelte/elements';
/**
* Determines if an HTML element is natively focusable.
*
* Checks whether a given tag with provided attributes can receive keyboard
* focus without needing an explicit `tabindex`. Elements are considered
* natively focusable if they have `tabindex`, `tabIndex`, `contenteditable`,
* or are inherently focusable tags like `button`, `input`, or anchors with `href`.
*
* @param tag - The HTML element tag name.
* @param attrs - Attributes object that may contain focusability hints.
* @returns `true` if the element is natively focusable, otherwise `false`.
*
* @example
* ```typescript
* isNativelyFocusable('button', {}) // true
* isNativelyFocusable('div', { tabindex: '0' }) // true
* isNativelyFocusable('a', { href: '/home' }) // true
* isNativelyFocusable('div', {}) // false
* ```
*/
export declare const isNativelyFocusable: (tag: keyof SvelteHTMLElements, attrs?: Record<string, unknown>) => boolean;