Skip to main content

Dynamic Zone

Controlled container that displays a dynamic zone.

Buttons at the bottom can be clicked to add new blocks into the zone, each block is displayed in the zone with header, footer, actions and the content is rendered through a render function provided by the parent component

Storybook Docs

Props

DynamicZone takes a <Block> generic type that extends IBaseBlock.

NameTypeDefaultDescription
blockOptions *IBaseBlockButton[]-Array of IBaseBlockButton, displays as buttons to add blocks at the bottom of the zone
blocks *Block[]-Array of Block, displays as list of DynamicZoneBlock
onAppendBlock *(blockType: string) => void-Callback function called when a block button is clicked to append a new block
onRenderBlockContent *(block: Block, index: number) => ReactElement-Callback function called when a block is being rendered in the list, parent needs to return the rendered content
onToggleBlock *(block: Block, index: number, opened: boolean) => void-Callback function called when a block's toggle button is clicked to open/close it
blockCardPropsCardProps-Extra props for the internal Card component, root of DynamicZoneBlock
blocksStackPropsStackProps-Extra props for the internal Stack component, child of the root Container
bottomContainerPropsContainerProps-Extra props for the internal Container component, child of the root Container
buttonsGroupPropsGroupProps-Extra props for the internal Group component, container of the button area
buttonsTextstring-Content of button area's optional header, inside a Text component
buttonsTextPropsTextProps-Extra props for the internal Text component, container of the button area's optional header
internalBlockCardPropsIDynamicZoneBlockInternalComponentProps-Extra internal component props passed to DynamicZoneBlock
...--extends Container Props, root container

IBaseBlock

NameTypeDefaultDescription
id *string-Used internally as keys and for other reasons, should be unique and not be modified once set
opened *boolean-Controlled value that determines if the block is opened or not
blockType *string-Type of the block being rendered, sent back to parent for render, used as a kind of block type ID here and in IBaseBlockButton
blockHeader *ReactNode-Content of the block header
blockFooterReactNode-Content of the block footer
blockActionsIAction<IDynamicZoneBlockReference>[]-Action(s) displayed to the right of the block header

IBaseBlockButton

NameTypeDefaultDescription
blockType *string-Type of the block being rendered, sent back to parent for render, used as a kind of block type ID here and in IBaseBlock
label *string-Label of button to add a new block

Dynamic Zone Block

Sub-component that renders one block with header, content and footer.

Props

NameTypeDefaultDescription
children *ReactNode-Main content of block
headerChildren *ReactNode-Content of header
onToggle *(opened: boolean) => void-Callback function called when opening/close button is clicked
opened *boolean-Controlled value the determines if the block's Collapse is open or closed
reference *IDynamicZoneBlockReference-Object used internally and sent back to parent in callbacks, declares a block's id, index and the total arrayLength of blocks
actionsIAction<IDynamicZoneBlockReference>[]-Array of IAction using IDynamicZoneBlockReference as T, displayed to the right of the header
footerChildrenReactNode-Optional content of footer
internalComponentPropsIDynamicZoneBlockInternalComponentProps-Group of extra internal component props
...--extends Card Props

IDynamicZoneBlockReference

NameTypeDefaultDescription
arrayLength *number-Total length of parent's blocks array
id *string-ID of the block
index *number-Index of the block in the parent's blocks array
...--extends Record<string, unknown>

IDynamicZoneBlockInternalComponentProps

NameTypeDefaultDescription
contentCollapsePropsCollapseProps-Extra props for the internal Collapse component
contentContainerPropsContainerProps-Extra props for the internal Container component
footerCardSectionPropsCardSectionProps-Extra props for the internal CardSection component
headerActionListPropsIActionListProps<IDynamicZoneBlockReference>-Extra props for the internal ActionList component
headerCardSectionPropsCardSectionProps-Extra props for the internal CardSection component
headerGroupPropsGroupProps-Extra props for the internal Group component
toggleComponentPropsIDynamicZoneBlockToggleProps-Extra props passed to the internal ActionIcon toggle button

IDynamicZoneBlockToggleProps

NameTypeDefaultDescription
actionIconPropsActionIconProps-Extra props for the internal ActionIcon component used as the toggle button
downIconReactNode-Content of toggle button in down state
upIconReactNode-Content of toggle button in up state