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

[docs] Clearly document the CSS syntax is supported #97

Open
oliviertassinari opened this issue May 26, 2024 · 1 comment
Open

[docs] Clearly document the CSS syntax is supported #97

oliviertassinari opened this issue May 26, 2024 · 1 comment
Assignees
Labels
docs Improvements or additions to the documentation status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@oliviertassinari
Copy link
Member

oliviertassinari commented May 26, 2024

Summary

Most of the community prefers the CSS syntax over the JavaScript syntax. At least, that's what I conclude from:

So this should be clearly documented, and honesty maybe even be the default. Inside the Material UI source, we have taken the habit of using the JavaScript syntax because it's better typed, so helps with avoiding regressions, but in the docs of Base UI, we went with the CSS syntax e.g. https://mui.com/base-ui/react-button/ for the same reason I'm opening this issue.

Even if you consider this from the perspective that the whole point of Pigment CSS is to bring CSS Modules closer to the components, then asking people to rewrite their style is a big ask, using the CSS syntax makes a lot more sense. Then it's just a matter of making sure Pigment CSS + https://stylelint.io/ works well.

I'm personally more used to the JavaScript syntax, e.g. what I used in https://github.com/oliviertassinari/react-conf-2024-pigment-css/blob/b2aae0b9c03df51960c90ff7b72246d50d372f1f/src/components/Pigment.tsx.

Examples

No response

Motivation

No response

Search keywords: -

@oliviertassinari oliviertassinari added docs Improvements or additions to the documentation status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 26, 2024
@brijeshb42
Copy link
Contributor

brijeshb42 commented May 30, 2024

There are some differences to using one over the other,

  1. If authoring generic components, variants api can't be used with css syntax in styled().
  2. We provide a way to use dynamic prop values and use it through css variables. This is available in object syntax but not in tagged template syntax (yet).

Other than these two, both syntax can achieve the desired result. For point 2 above, I know that Linaria provides a way to do what we provide for css variables, but in Pigment, we have replaced that syntax to access theme object -

css`
 color: ${({ theme }) => theme.palette.primary.main}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

No branches or pull requests

2 participants