Replies: 2 comments 2 replies
-
try moving the const SelectItem = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item> & { imgSrc: string }
>(({ className, children, imgSrc, ...props }, ref) => (
<SelectPrimitive.Item
ref={ref}
className={cn(
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
className
)}
{...props}
>
<span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
<SelectPrimitive.ItemIndicator>
<CheckIcon className="h-4 w-4" />
</SelectPrimitive.ItemIndicator>
</span>
<SelectPrimitive.ItemText>
<div className="flex">
{/* Display the image */}
{imgSrc && (
<img
src={imgSrc}
alt="Icon"
className="h-5 w-5 mr-2 rounded-full"
/>
)}
{children}
</div>
</SelectPrimitive.ItemText>
</SelectPrimitive.Item>
))
SelectItem.displayName = SelectPrimitive.Item.displayName |
Beta Was this translation helpful? Give feedback.
1 reply
-
You can do something like this
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Question
I'd like to add an image to the Select component, similar to an avatar.

Here's what I tried:
But I don't want to customize the selected value, how do I modify the SelectValue
const SelectValue = SelectPrimitive.Value
Beta Was this translation helpful? Give feedback.
All reactions