Release 0.16.0
This release adds support for a long-requested feature—descendant and sibling selectors! We've also expanded defineConsts capabilities, improved our lint rules, added a webpack example, and made some performance optimizations.
Descendant and sibling selectors
We’re adding a new suite of APIs under stylex.when with support for descendant and sibling selectors: ancestor, descendant, anySibling, siblingBefore, and siblingAfter.
- Ancestor/descendant (
stylex.when.ancestorandstylex.when.descendant) selectors let you style an element based on the state of ancestors or descendants in the DOM tree. - Sibling selectors (
stylex.when.anySibling,stylex.when.siblingBeforeandstylex.when.siblingAfter) let you style an element based on the state of adjacent siblings.
To use descendant and sibling selectors, you'll need to mark the element being observed by passing the stylex.defaultMarker class name. Support for custom markers will be added in a future release.
import * as stylex from '@stylexjs/stylex';
const styles = stylex.create({
foo: {
backgroundColor: {
default: 'blue',
[stylex.when.ancestor(':hover')]: 'red',
},
},
});
<div {...stylex.props(stylex.defaultMarker())}>
<div {...stylex.props(styles.foo)}> Some Content </div>
</div>



