Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to select by data attributes? #403

Open
asherccohen opened this issue Jun 10, 2021 · 0 comments
Open

Is it possible to select by data attributes? #403

asherccohen opened this issue Jun 10, 2021 · 0 comments

Comments

@asherccohen
Copy link

It's becoming popular for styleless component libraries to write state into data attributes, is there a syntax for styletron to read that state?

Here is an example from Radix UI using the stiches CSS-in_JS lib:

const StyledTab = styled(Tabs.Tab, {
  flexShrink: 0,
  padding: '10px 20px',
  color: 'slategray',
  userSelect: 'none',

  '&:hover': { color: 'black' },

  '&[data-state="active"]': { // we read state from data attributes and use it to style the element
    color: 'black',
    boxShadow:
      'inset 0 -1px 0 0 currentColor, 0 1px 0 0 currentColor',
  },
});

If not, can I suggest a feature like this to be included?

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant