This repository has been archived by the owner on Jan 23, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 480
Floating Label #1637
Comments
for react select I solved using this: import React from 'react';
import { GroupBase, OptionsOrGroups, Select } from 'chakra-react-select';
import { FormikProps } from 'formik';
type Props = {
options: OptionsOrGroups<
{ value: any; label: string },
GroupBase<{ value: any; label: string }>
>;
name: string;
formik: FormikProps<any>;
value: any;
};
const Component = ({ options, name, formik, value }: Props) => {
return (
<Select
classNamePrefix="chakra-react-select"
chakraStyles={{
menu: (provided, state) => ({
...provided,
zIndex: 3,
}),
}}
placeholder=""
id={name}
name={name}
onChange={(option) => formik.setFieldValue(name, option?.value)}
onBlur={formik.handleBlur}
options={options}
value={value}
/>
);
};
export default Component; |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Subject
Floating Label
Description
I've found out that in this recipe: https://chakra-ui.com/community/recipes/floating-labels.
There is
zIndex: 2
but I thinkzIndex: 1
is enought and it conflict with less components (i.e. https://www.npmjs.com/package/react-datepicker).my setup to makes datepicker works with floating:
Form theme string label =
'input:not(:placeholder-shown) + label, .chakra-react-select--has-value + label, .chakra-datepicker--has-value + label, .chakra-select__wrapper + label, textarea:not(:placeholder-shown) ~ label':
DatePicker Component =
and... I wonder if there is a way to make it works without conflict at all with other elements (i'm having trouble with https://www.npmjs.com/package/react-select)
The text was updated successfully, but these errors were encountered: