function / @typed/ui/index

Composite.focusElement

Calls an existing platform focus method inside Effect.sync and otherwise does nothing.

Learn this UI primitive →

Package version
1.0.0-beta.13
Category
DOM focus and scrolling
Since
1.0.0
Member of
Composite

Import

import { Composite } from "@typed/ui/index";

Access Composite.focusElement through the imported Composite export. Its declaration below describes the member.

This public exposure is a re-export. Its import path is supported; declaration documentation is shared with the other public exposures below.

Signatures

export declare function focusElement(element: object | undefined): Effect.Effect<void>;

Why

The operation exposes Composite’s transition directly so callers can compose it in Effect programs and native event handlers.

Ownership and lifetime

The returned Effect performs the update or DOM side effect only when run, preserves the declared error and service channels, and retains no resources after completion.

Examples

import * as Composite from "@typed/ui/Composite";

const focused = Composite.focusElement(document.querySelector("button") ?? undefined);

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source