add focus element utility

This commit is contained in:
Elijah Duffy
2025-07-01 14:58:05 -07:00
parent ed18e08a47
commit c01dd71023
2 changed files with 13 additions and 0 deletions

9
util.ts Normal file
View File

@@ -0,0 +1,9 @@
import type { Action } from 'svelte/action';
/**
* Focuses the given HTML element.
* @param node - The HTML element to focus.
*/
export const focus: Action<HTMLElement> = (node) => {
node.focus();
};