Skip to content

Function attachSlots() ​

Call Signature ​

attachSlots<T, S>(root: T, slots: S, name?: string): T & S

Source: slots.tsx

Attaches slot components to a root component as properties and names them.

Type Parameters ​

T ​

T extends FC<Record<string, FC>>

S ​

S extends Record<string, FC> = InferSlots<ComponentProps<T>>

Parameters ​

root ​

T

The root component.

slots ​

S

The slot components.

name? ​

string

The name of the root component. Usually matches the name passed to createSlots. Defaults to the displayName or the function name of root.

Returns ​

T & S

The root component with the slot components attached to it.

Example ​

tsx
const Accordion = attachSlots(AccordionRoot, {
  Summary: AccordionSummary,
  Details: AccordionDetails,
});

Usage ​

tsx
<Accordion>
	<Accordion.Summary/>
	<Accordion.Details/>
</Accordion>

Call Signature ​

attachSlots<T, S>(root: T, slots: S, name?: string): T & S

Type Parameters ​

T ​

T extends FC

S ​

S extends Record<string, FC>

Parameters ​

root ​

T

slots ​

S

name? ​

string

Returns ​

T & S

Inherit Doc ​

Built by Prozilla