Slot
A utility component for flexible component composition through prop merging.
Credits
This was inspired entirely by the Slot component from Radix UI and works exactly the same way, but has been optimized in certain areas.
API Reference
Slot Props
Accepts all valid HTML element props which will be merged with the child element's props.
Slottable Props
| Prop | Type | Description |
|---|---|---|
children | React.ReactNode | The element to receive merged props |
Implementation Details
The Slot component works by:
- Checking for Slottable children and handling them specially
- Merging props between parent and child elements
- Composing refs if both parent and child have them
- Special handling for React fragments
- Validation of child counts and element types