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.

Referência

Assinaturas

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

Parâmetros de tipo

NomeRestriçãoPredefinição
T——

Parâmetros

NomeTipoObrigatórioDescrição
propsForProps<T>Sim—

Devolve

KuitoElement

Props: ForProps<T>

Props (incluindo props herdadas) 4

NomeTipoObrigatórioDescrição
eachreadonly T[] | ReadonlySignal<readonly T[]>SimThe items: an array, a signal of one, or a store array.
fallbackKuitoNodeNãoRendered while each is empty.
children(item: T, index: ReadonlySignal<number>) => KuitoNodeSimRenders an item's row once; index follows its position.
keystring | numberNão—
children — assinaturas de método

Assinaturas

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

Parâmetros

NomeTipoObrigatórioDescrição
itemTSim—
indexReadonlySignal<number>Sim—

Devolve

KuitoNode

Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.