Skip to content
HomePagesHomePages template kit

select

The select slot AND the `meta.display` entry, told apart by the call shape.

The select slot AND the meta.display entry, told apart by the call shape.

As a slot: select({ from }) for a fact-derived vocabulary, select.of([…]) for a hand-authored one. Binding-only: no fill decision produces a single select value, so the slot form takes no fill. A top-level select is bound with source; a select inside a record item is written by the list’s own chooseFrom origination, which picks from this field’s vocabulary.

As a display entry: select(cases, { source: compute(fn) }) or select(cases, { fill: chooseFrom({ pick }) }) declares a meta.display visibility/variant — the first case is the default and the failure posture, locked: true opts a variant out of user switching, and the entry takes exactly one origin.

Import from @homepages/template-kit.

function select<const HasSource extends SlotSource | ComputeBinding<unknown> | undefined = undefined>(opts: SelectOptions & { source?: HasSource; } & WritebackOption<HasSource>): SelectSlotDef & SourceMark<HasSource>
function select<const C extends readonly [string, ...string[]]>(cases: C, opts: { locked?: boolean; } & DisplayOriginOptions<C>): DisplayEntryInput<C>

SelectSlotDef & SourceMark<HasSource>

import { chooseFrom, compute, select } from "@homepages/template-kit";
select.of(["for_sale", "sold"], { label: "Status" });
select(["visible", "hidden"], { source: compute((f) => (f.tours.length > 0 ? "visible" : "hidden")) });
select(["classic", "editorial"], { fill: chooseFrom({ pick: "Prefer editorial for story-driven narratives." }) });