ForProps
Props of For: the items, the row each renders, and what shows while there are none.
Usage
Render a short checklist
This type is used by For
import { For, Scroll, Text, store } from 'kuito';
export function PackingList() {
const state = store({ items: [{ title: 'Passport' }, { title: 'Tickets' }] });
return (
<Scroll>
<For each={state.items} fallback={<Text>Add your first item</Text>}>
{(item, index) => <Text padding={12}>{`${index.value + 1}. ${item.title}`}</Text>}
</For>
</Scroll>
);
}Type declaration
export interface ForProps<T> extends ElementAttributes {
/** The items: an array, a signal of one, or a store array. */
each: readonly T[] | ReadonlySignal<readonly T[]>;
/** Rendered while `each` is empty. */
fallback?: KuitoNode;
/** Renders an item's row once; `index` follows its position. */
children: (item: T, index: ReadonlySignal<number>) => KuitoNode;
}Members 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.