Skip to content

Adding floating labels to Creatable Select #93

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

You must be logged in to vote

This was an interesting challenge for me so I gave it a shot! I ended up coming up with two ways to do this, one of which involved a small patch I added into the most recent version of chakra-react-select, 3.2.0.

First Way

The first way which was simple enough to add in the way chakra-react-select previously worked was just to check if a value was selected and add the custom style to the label manually. Here's an example of how to do that:

CodeSandbox: https://codesandbox.io/s/chakra-react-select-floating-labels-6eyic1?file=/example.js

import { useState } from "react";
import { FormControl, FormLabel } from "@chakra-ui/react";
import { CreatableSelect } from "chakra-react-select";

const E…

Replies: 5 comments 1 reply

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
Comment options

You must be logged in to vote
1 reply
@csandman
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #83 on May 05, 2022 01:23.