Skip to content

Autofocus

Bindings for @solid-primitives/autofocus.

let createAutofocus(ref: unit -> #HtmlElement): unit

Pass an accessor that returns the element to focus: one that reads a captured ref, or a signal that the element's ref sets. Upstream usage:

let ref;
createAutofocus(() => ref);
<button ref={ref}>Autofocused</button>;

const [ref, setRef] = createSignal();
createAutofocus(ref);
<button ref={setRef}>Autofocused</button>;
Edit this page