You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using an attribute on the child to determine where it is rendered in the container seems untypical for React, so is the term "slot". It's also uncommon, and potentially confusing, to be able to put multiple children into the same location by putting them on the same hierarchy level and repeating the same value for the slot attribute, usually you would use a wrapper component or fragment to group them explicitly together.
More common approaches are a prop on the container component, or a special wrapper component that tells the container where to put the child. For example for adding a prefix or suffix to an input / text field, this is how other libraries do it:
Using props would align with some existing APIs, for example header / footer in Dialog or GridColumn.
This affects a whole bunch of components, the effective list would need to be compiled when going ahead with this.
One concern regarding using props is readability, for example an app layout could look very cluttered if you have to dump all your drawer / nav bar contents into a prop of the component:
In cases where a lot of content is expected we could chose to use a wrapper component pattern instead (AppLayoutDrawer). Or keep using props, and advise to extract content into separate variables or components. The latter is probably preferable over having different ways of doing the same thing, and quite common from my experience.
The text was updated successfully, but these errors were encountered:
Currently you need to use the slot attribute inherited from the web component to place a child into a specific location of the container:
Using an attribute on the child to determine where it is rendered in the container seems untypical for React, so is the term "slot". It's also uncommon, and potentially confusing, to be able to put multiple children into the same location by putting them on the same hierarchy level and repeating the same value for the slot attribute, usually you would use a wrapper component or fragment to group them explicitly together.
More common approaches are a prop on the container component, or a special wrapper component that tells the container where to put the child. For example for adding a prefix or suffix to an input / text field, this is how other libraries do it:
startAdornment
/endAdornment
propsprefix
/suffix
propsInputLeftAddon
/InputRightAddon
wrapper componentsFor the number field above, an alternative could be to use a prop like this:
Using props would align with some existing APIs, for example
header
/footer
inDialog
orGridColumn
.This affects a whole bunch of components, the effective list would need to be compiled when going ahead with this.
One concern regarding using props is readability, for example an app layout could look very cluttered if you have to dump all your drawer / nav bar contents into a prop of the component:
In cases where a lot of content is expected we could chose to use a wrapper component pattern instead (
AppLayoutDrawer
). Or keep using props, and advise to extract content into separate variables or components. The latter is probably preferable over having different ways of doing the same thing, and quite common from my experience.The text was updated successfully, but these errors were encountered: