Placeholder
Render a centred icon and message for empty states.
Placeholder is a client component ("use client") that renders a Text as a centred flex column, with an optional Icon block above its children. Use it for empty states, such as an empty list or a page without access.
Import#
import { Placeholder } from "@reactberry/system/blocks";
Usage#
import { Placeholder } from "@reactberry/system/blocks";
import { Button, Text } from "@reactberry/system/elements";
export default function EmptyFiles() {
return (
<Placeholder icon="Icon24Folder" skin="surface" shape="rounded" minHeight="16rem">
<Text fontWeight="600" color="primary">
No files yet
</Text>
<Button variant="primary" $size="small">
Upload a file
</Button>
</Placeholder>
);
}
Examples#
Icon styling#
Without icon, the "IconDocFolder" icon is shown. Pass another registered name, and use iconProps to change its colour or size.
Icon component#
Pass a component from @reactberry/system/icons instead of a name.
Text only#
Set icon={null} to render only the children.
API#
Placeholder#
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Rendered below the icon. |
icon | string | ComponentType<any> | null | IconDocFolder | A registered icon name (rendered via |
iconProps | any | — | Spread onto the icon after its defaults ( |
All other props are spread onto the Text after these defaults: as="div", display="flex", flexDirection="column", justifyContent="center", alignItems="center", fontSize="small", p="medium", gap="s", color="tertiary".
Accessibility#
- The root is a plain
divwith no role. Addrole="status"if the empty state appears in response to a user action, such as filtering. - The icon is rendered without an accessible name or
aria-hidden.
Notes#
- With no
iconprop, the registered"IconDocFolder"icon is rendered. String names must be registered (see theIconpage); unknown names log a warning fromIconand render no icon. - A component passed as
iconreceives the same defaults andiconPropsas the string form, but is rendered directly rather than looked up by name. SkeletonusesPlaceholderinternally for its loading blocks.