I'm trying to get Styled Components to work with selecting the closest span element
<label>
<span className="">Password</span>
<input type="password" id="passwordInput" />
</label>
span {
position: absolute;
font-size: 14px;
height: 40px;
color: #a2a2a2;
line-height: 40px;
right: 0;
left: 8px;
cursor: auto;
}
input {
height: 40px;
padding-left: 8px;
padding-top: 10px;
padding-bottom: 10px;
width: 100%;
border: 1px solid #dbdbdb;
background-color: #fafafa;
border-radius: 3px;
cursor: auto;
font-size: 16px;
&:focus {
& + span {
background-color: red;
}
outline: #a2a2a2;
border: 1px solid #a2a2a2;
}
}
I'm not sure how to go about it, this is what I'm trying right now and it's not working. Preferably I would like to have them work without giving the span, specific classes.