Replies: 2 comments 4 replies
-
This appears to work perfectly to me! Here's a functional example: https://codesandbox.io/s/jjimj0?file=/app.tsx The one thing to make sure of is that you're using the import React, { useState } from "react";
import { Container, FormControl, FormLabel } from "@chakra-ui/react";
import { Select, OptionBase } from "chakra-react-select";
import countries from "./data/countries";
interface CountryOption extends OptionBase {
label: string;
value: string;
}
const App: React.FC = () => {
const [selectedColors, setSelectedColors] = useState<
readonly CountryOption[]
>([]);
return (
<Container mb={16} maxW="sm">
<FormControl p={4}>
<FormLabel>chakra-react-select automatically sized menu</FormLabel>
<Select
isMulti
name="countries"
options={countries}
placeholder="Select some countries..."
closeMenuOnSelect={false}
value={selectedColors}
onChange={setSelectedColors}
chakraStyles={{
menu: (base) => ({
...base,
width: "max-content",
minWidth: "100%",
}),
}}
/>
</FormControl>
</Container>
);
};
export default App; |
Beta Was this translation helpful? Give feedback.
4 replies
-
@csandman Hello, and how in new version I can have old style? I want to have fixed width |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In the vanilla react-select, you could get a automatically sized component with:
but this doesn't work in chakra-react-select. What do I need to do differently?
Beta Was this translation helpful? Give feedback.
All reactions