DocsBlog
  • 1.2.1

  • light

    dark

    system

    Switch mode
  • Cerberus

    Acheron

    Elysium

Get Started
Components
Data Grid
Signals
Styling
Theming

Concepts

OverviewCompositionCerberus ContextTesting

Layout

Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridGroupLink OverlayScrollableStackWrap

Components

AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMenuNotificationsNumber InputPaginationPin InputPopoverNewProgressPrompt ModalRadioRatingSelectSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

Utilities

Client OnlyDownload TriggerEnvironmentFeature FlagsFocus TrapForFormat ByteFormat NumberFormat Relative TimeFrameHighlightJSON Tree ViewLocaleLocal StoragePortalPresenceShowsplitPropsTheme

For

Render a list of components or a fallback. Inspired by SolidJS.

  • npm
  • source
import { For } from '@cerberus/react'

Usage

The For component is used to render a list of components or a fallback. It is an abstraction of the Array.map method.

Copy
for demo
import { For, Text } from '@cerberus/react'
import { VStack } from 'styled-system/jsx'
function ForPreview() {
const data = ['Cerberus', 'Design', 'System', 'Roolz', 'D00dz']
return (
<VStack alignItems="flex-start" gap="md">
<For each={data}>
{(item, index) => (
<Text key={item} textStyle="body-lg">
{index}. {item}
</Text>
)}
</For>
</VStack>
)
}

API

export interface ForProps {
each: any[]
fallback?: ReactNode
}
define function For(props: ForProps): ReactNode | null

Props

The For component accepts the following props:

NameDefaultDescription
eachAn Array of items to loop through.
fallbacknullThe content to render when the each value is empty.

On this page

Loading...

Loading...

Loading...

Loading...

0. Cerberus

1. Design

2. System

3. Roolz

4. D00dz

On this page

  • Edit this page on Github