Skip to content

Conversation

@BrknRules
Copy link

@BrknRules BrknRules commented Jan 28, 2026

This adds a renderValue prop to Picker S2, which allows users to render custom elements within the Picker's select based off of selected items (could also just render a custom element regardless of selection as well, TBD).

To Do

  • Bikeshed prop name (renderSelectedItems, renderValue, ...?)
  • Implement types
    • Improve renderValue type, atm just uses SelectValue.children but should restrict
  • Implement rendering custom react elements based off of selected items
  • Tests
  • Docs

* Custom renderer for the selected value shown in the button.
* Matches the `SelectValue` children render type.
*/
renderValue?: SelectValueProps<T>['children']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just pass in the selected items (i.e. (selectedItems: T[]) => ReactNode) here, and only call it when there is at least one item selected. We already have the placeholder prop to customize the placeholder text, and you can omit renderValue if you want the default text. Is that sufficient for your use case or did you need one of the other render props?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's enough for our use case -- was probably being too proactive trying to think of a general situation.

@BrknRules BrknRules force-pushed the S2-Picker-renderValue branch from 0645caf to 7f8c3fd Compare February 3, 2026 10:57
@BrknRules BrknRules force-pushed the S2-Picker-renderValue branch from 7f8c3fd to d5c4f3c Compare February 3, 2026 11:31
@BrknRules BrknRules requested a review from devongovett February 3, 2026 11:52
Copy link
Author

@BrknRules BrknRules left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some notes on implementation choices -- would appreciate thoughts!

display: 'flex',
alignItems: 'center'
alignItems: 'center',
height: '100%'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locked height to picker button height. Enough for our use case as we don't have anything larger than the button that should cause it to resize.

<SelectValue
className={
valueStyles({isQuiet}) +
(renderValue ? '' : ' ' + raw('&> :not([slot=icon], [slot=avatar], [slot=label], [data-slot=label]) {display: none;}'))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was quite restrictive in allowing us our own layouts. This should allow custom layouts only through renderValue and not via slot manipulation.

@BrknRules BrknRules marked this pull request as ready for review February 4, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants