Slot

Slot implements a flexible composition pattern for components that need to render as different elements. Sometimes a Button component must render as a native button or as an a depending on usage. Slot merges parent props into the chosen child element while preserving styles, event handlers, and refs.

Basic usage#

Use the asChild pattern to let consumers control the rendered element while maintaining the component's styling and behavior.

Slottable#

Wrap parts of complex structures with Slottable to pass props to specific child elements—useful for buttons with icons or compound components.

Components - Control Flow Utilities | ilokesto - React Library Collection