S
S
Sergey2020-07-01 23:48:05
React
Sergey, 2020-07-01 23:48:05

How to change the style of the label pseudo-element?

I made a custom checkbox through a pseudo-element. How to add a style to it in React when processing a click?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Proskurin, 2020-07-03
@Banjamin

You can't directly. It needs to be through a parent.
You also hang an additional class (modifier) ​​on the label,

<label htmlFor={el.name} className={el.checked ? 'checked' : null}>{el.name}</label>

and in the styles set the necessary properties
label.checked {
    &::after{
        /* стили */
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question