Skip to content

Allow any React.ReactNode to be a label #109

Answered by csandman
lcswillems asked this question in Q&A
Discussion options

You must be logged in to vote

Ah ok, that makes more sense. However, you aren't fully out of options. One way you could get the behavior you're looking for is by extending the Option component exported from this package to render custom elements you keep on your options object. This feature is explained in depth in the react-select docs

Here's a quick example I made demonstrating how to do it: https://codesandbox.io/s/chakra-react-select-custom-option-d99s7?file=/example.js

import { Icon } from "@chakra-ui/react";
import { Select, chakraComponents } from "chakra-react-select";
import {
  GiJellyBeans,
  GiChocolateBar,
  GiStrawberry,
  GiCherry
} from "react-icons/gi";

const flavorOptions = [
  {
    value: "vanilla",

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by csandman
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Won't Fix This will not be worked on Workaround A workaround exists
2 participants
Converted from issue

This discussion was converted from issue #41 on May 05, 2022 19:34.