Render a short collection while preserving item identity. Use it for tags, checklist rows and small menus.

Show a checklist with row numbers

tsx
import { For, Scroll, Text, store } from 'kuito';

const todo = store({ tasks: [{ title: 'Write', done: false }] });

export default function Tasks() {
  return (
    <Scroll>
      <For each={todo.tasks} fallback={<Text>Nothing to do</Text>}>
        {(task, index) => <Text>{index.value + 1 + '. ' + task.title}</Text>}
      </For>
    </Scroll>
  );
}

Behavior

each accepts an array, array signal or store array. index is a signal. Every item is mounted; choose List when the collection needs virtualization. fallback handles an empty collection.

Continue

Read Control flow for a complete workflow. See the complete prop reference for types and documented defaults.

Referenz

Signaturen

ts
<T>(props: ForProps<T>): KuitoElement

Typparameter

NameEinschränkungStandard
T——

Parameter

NameTypErforderlichBeschreibung
propsForProps<T>Ja—

Rückgabe

KuitoElement

Props: ForProps<T>

Props (einschließlich geerbter Props) 4

NameTypErforderlichBeschreibung
eachreadonly T[] | ReadonlySignal<readonly T[]>JaThe items: an array, a signal of one, or a store array.
fallbackKuitoNodeNeinRendered while each is empty.
children(item: T, index: ReadonlySignal<number>) => KuitoNodeJaRenders an item's row once; index follows its position.
keystring | numberNein—
children — Methodensignaturen

Signaturen

ts
(item: T, index: ReadonlySignal<number>): KuitoNode

Parameter

NameTypErforderlichBeschreibung
itemTJa—
indexReadonlySignal<number>Ja—

Rückgabe

KuitoNode

Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.