My CSS situation:
.input-wrapper {
display: flex;
flex-direction: column;
align-items: stretch;
width: 100%;
}
.input-label {
display: block;
font-size: 12px;
font-weight: bold;
color: something;
}
.input {
padding-bottom: 0.5rem;
margin-bottom: 0.5rem;
position: relative;
border: none;
border-bottom: 2px solid grey;
background-color: transparent;
text-align: left;
outline: none;
overflow-wrap: break-word;
overflow: hidden;
resize: none;
width: 100%;
&:focus {
border-bottom-color: red;
}
}
My JSX:
const [focused, setFocused] = useState<boolean>(false);
const handleOnBlur = () => {
setFocused(false);
onBlur && onBlur();
};
const handleOnFocus = () => {
setFocused(true);
};
const valueHasLength = value.length > 0;
return (
<div className="input-wrapper">
{focused && valueHasLength && <label className='input-label'>{labelText}</label>}
<input
className='input'
placeholder='placeholder'
value={value}
onChange={onChange}
onFocus={handleOnFocus}
onBlur={handleOnBlur}
/>
</div>
)
The video is also attached. I basically want the label to appear but not make the input field drop down because of that as it breaks the alignment with the comma and the other input field. Any help?