Check for empty slots
isEmptySlot(node)
Call isEmptySlot from @webflow/react to check whether a Slot prop has children.
Use isEmptySlot when you need to:
- Render fallback content when a designer hasn’t added children to a slot.
- Hide a wrapper when a slot is empty.
Syntax
Parameters
Returns
true if the slot is empty. false if the slot has children.
isEmptySlot also returns true when node is null or undefined. That covers rendering the component outside Webflow, such as local development or tests.
Limitations
isEmptySlotreports a slot as filled if it has children, even when those children render nothing. An empty fragment or a child hidden by a visibility binding still counts as filled.- Only Slot props (
props.Slotorprops.Children) report emptiness. Rich Text and Text Node props always report as filled.
Best practices
Render fallback content next to the slot, not instead of it. Replacing the slot removes the Designer drop target.
Examples
Render fallback content next to a slot
In this example, the card still mounts the slot so designers can drop content. When the slot is empty, it also shows fallback text.
Wrap a component that treats missing content as empty
If an existing component renders its own placeholder when content is null or undefined, wrap it for Webflow. Pass null for empty slots. Default the edit prop to true so the slot stays mounted as a Designer drop target. Turn edit off to preview how the wrapped component handles empty content.