Skip to main content

Signature

Parameters

Component
required
The parent component that will receive the slots.
object
required
An object mapping slot names to components.

Returns

The original component with slot components attached as static properties.

Examples

Basic

With Context

Extending Slots

Add more slots to an existing compound component:

Multiple Levels

Slots can have their own slots:

Behavior

displayName Preservation

withSlots preserves the original component’s displayName for React DevTools:

No Restriction on Children

Slots don’t restrict what children a component can accept. They’re just a convenient way to access related components.

Slot Overwriting

If you add a slot with the same name as an existing one, the new slot replaces it:

See Also