slottr

slottr

  • Docs
  • API
  • Help
  • Blog

›slottr API

slottr API

  • Slottable components
  • Filter Slot

Slottable components

The main component created by the createSlot function accepts and passes the same props as the component or JSX element indicated.

Component

NameTypeDescription
renderAsReact.ComponentType ⎮ keyof JSX.IntrinsicElementsElement injected for rendering instead of default. Any props will have to be compatible.

Component.Slot

The slot consumes an array of children and filters for ones marked as the component

NameTypeDescription
scopeany ⎮ ScopeMapElements passed for filtering, indexed using useScope
children?anyDefault children of element, if any.
defaultProps?JSX.IntrinsicAttributes & React.PropsWithChildren<T>default props to use with default element
passedProps?Tprops passed to the element from the component containing the slot
multiple?booleanDisplay all if multiple slots are passed
withContext?booleanComponents are composed through their immediate children
fallback?anyfallback to use if slot is not used
fallbackProps?JSX.IntrinsicAttributes & React.PropsWithChildren<T>default props to use with default element
childIs?'feedback' ⎮ 'default' ⎮ 'both'Designate the children prop as the default element, the fallback element or both

Component.SubSlot

Same as Slot, but takes in a React Context propagated by the Slot with the withContext option. All other props are passed into the Slot. The context of the SubSlot can be accessed from a Component.Slot above it in the hierarchy by accessing Component.Context.

Warning! All SubSlot elements must be placed inside the Slot element propagating the context, and its context must be enabled in the slot template. Otherwise, a critical React error will occur, as a Context Consumer is created without a Context Provider above it in the hierarchy.

NameTypeDescription
scopeReact.ContextElements passed for filtering
Filter Slot →
  • Component
  • Component.Slot
    • Component.SubSlot
slottr
Docs
Getting StartedGuidesAPI Reference
Community
Coming soon...
More
BlogGitHubStar
Copyright © 2019 kirillvy