Input psudo-elements inside of psudo-classes #116
-
Hi, I need to convert an input checkbox element that was written with CSS modules into stylex styling .checkbox {
width: 1rem;
height: 1rem;
flex-shrink: 0;
border-radius: var(--radius-xs, 0.25rem);
border: 1px solid var(--colors-border-border-primary, #d0d5dd);
}
.checkbox:after {
content: " ";
background: var(--colors-background-bg-brand-solid, #7f56d9);
display: inline-block;
visibility: visible;
}
.checkbox:checked::after {
display: flex;
width: 1rem;
height: 1rem;
padding: var(--spacing-none, 0.125rem);
justify-content: center;
align-items: center;
gap: var(--spacing-none, 0rem);
flex-shrink: 0;
border-radius: var(--radius-xs, 0.25rem);
content: url("/icons/check.svg");
color: white;
}
.checkbox:focus {
border-radius: var(--radius-xs, 0.25rem);
border: 1px solid var(--colors-border-border-primary, #d0d5dd);
background: var(--colors-background-bg-primary, #fff);
/* Focus rings/ring-gray */
box-shadow: 0px 0px 0px 4px rgba(152, 162, 179, 0.14);
}
.checkbox:focus:checked {
border-radius: var(--radius-xs, 0.25rem);
background: var(--colors-background-bg-brand-solid, #7f56d9);
/* Focus rings/ring-brand */
box-shadow: 0px 0px 0px 4px rgba(158, 119, 237, 0.24);
} My problem is that there is a ::after element styling inside of a :checked psudo-class, which is a problem because psudo-elements must be defined as a top-level key within a namespace. Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The limitation here is that we don't yet support descendent and sibling selectors. We're working on a proposal to share to add this feature soon. In the meantime, as a workaround, you can make this work for now by using CSS variables. 1. Define a
|
Beta Was this translation helpful? Give feedback.
The limitation here is that we don't yet support descendent and sibling selectors. We're working on a proposal to share to add this feature soon.
In the meantime, as a workaround, you can make this work for now by using CSS variables.
1. Define a
checkbox-tokens.stylex.ts
file:2. Import and the variables: