For
Render a short collection while preserving item identity. Use it for tags, checklist rows and small menus.
Show a checklist with row numbers
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.
Reference
Signatures
<T>(props: ForProps<T>): KuitoElementType parameters
| Name | Constraint | Default |
|---|---|---|
T | — | — |
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
props | ForProps<T> | Yes | — |
Returns
Props: ForProps<T>
Props (including inherited props) 4
| Name | Type | Required | Description |
|---|---|---|---|
each | readonly T[] | ReadonlySignal<readonly T[]> | Yes | The items: an array, a signal of one, or a store array. |
fallback | KuitoNode | No | Rendered while each is empty. |
children | (item: T, index: ReadonlySignal<number>) => KuitoNode | Yes | Renders an item's row once; index follows its position. |
key | string | number | No | — |
children — method signatures
Signatures
(item: T, index: ReadonlySignal<number>): KuitoNodeParameters
| Name | Type | Required | Description |
|---|---|---|---|
item | T | Yes | — |
index | ReadonlySignal<number> | Yes | — |
Returns
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.