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
Autocomplete has getOptionLabel for the simple case of rendering a string (usually when the value and option are the same type), and renderOption that is more like a render prop.
Applying this pattern to Base's Select could look like:
Keep the renderValue: (selectedValue) => ReactNode for the "simple" case, maybe rename it to be the equivalent of getOptionLabel (e.g. getValueLabel? getValueDisplay?)
Have a "proper" render prop for the value that provides additional arguments, e.g. ownerState
This may allow more flexibility, but it is quite different from Material UI's current API
Proposed solution π’
I think Base UI's Select's current renderValue is already quite sufficient, it has parity with Material UI, and the layout shift issue was fixed
Having two props for rendering the value like Autocomplete doesn't seem worth it for the additional mental overhead of a new prop, and it would deviate more from the current Select APIs
Maybe it would be enough if we pass ownerState to renderValue as a 2nd argument to provide more customization flexibility. At the risk of bloating this too much, we could even additionally accept options and pass that into ownerState as well
I think Base UI's Select's current renderValue is already quite sufficient, it has parity with Material UI, and the layout shift mui/material-ui#38796 was fixed
michaldudak
changed the title
[RFC][Select][base-ui] Rendering the selected value in SSR & during hydration
[RFC][Select] Rendering the selected value in SSR & during hydration
Feb 27, 2024
What's the problem? π€
Raised in #37, to refine the
renderValue
API to support renderingSelect
's selected value in SSR and during hydrationWhat are the requirements? β
What are our options? π‘
1. Provide an
options
propuseSelect
already accepts an optionaloptions
param, though it will ignore JSX childrenThe
Select
component does not pass (or even accept)options
to the underlyinguseSelect
.Though it may be asking too much from the user, it could be optional for those that need it.
Related - possibly related, raised in this (old) issue, why options aren't provided by
renderValue
:2. An
Autocomplete
-like APISuggested in #37
Autocomplete has
getOptionLabel
for the simple case of rendering a string (usually when thevalue
andoption
are the same type), andrenderOption
that is more like a render prop.Applying this pattern to Base's Select could look like:
renderValue: (selectedValue) => ReactNode
for the "simple" case, maybe rename it to be the equivalent ofgetOptionLabel
(e.g.getValueLabel
?getValueDisplay
?)ownerState
This may allow more flexibility, but it is quite different from Material UI's current API
Proposed solution π’
I think Base UI's Select's current
renderValue
is already quite sufficient, it has parity with Material UI, and the layout shift issue was fixedHaving two props for rendering the value like Autocomplete doesn't seem worth it for the additional mental overhead of a new prop, and it would deviate more from the current Select APIs
Maybe it would be enough if we pass
ownerState
torenderValue
as a 2nd argument to provide more customization flexibility. At the risk of bloating this too much, we could even additionally acceptoptions
and pass that intoownerState
as wellResources and benchmarks π
The text was updated successfully, but these errors were encountered: