mui / pigment-css

Pigment CSS is a zero-runtime CSS-in-JS library that extracts the colocated styles to their own CSS files at build time.
MIT License
389 stars 18 forks source link

[docs] Create docs to recommend when to use each API #100

Open oliviertassinari opened 1 month ago

oliviertassinari commented 1 month ago

Steps to reproduce

We have 3 main APIs in Pigment CSS: https://react-conf-2024-pigment-css.netlify.app/?slideIndex=31&stepIndex=0

code-example

I would much rather not make the same mistake as in https://youtu.be/UlY-Ixddjm0?si=WTs9IU9K47mOfUzE&t=1538. Meaning, we should document clearly when to use each prop so developers get consistency.


styled API:

Pros:

Cons:

Current behavior

No response

Expected behavior

No response

Context

No response

Your environment

npx @mui/envinfo ``` Don't forget to mention which browser you used. Output from `npx @mui/envinfo` goes here. ```

Search keywords: -

damusnet commented 4 weeks ago

@oliviertassinari does/will Pigment CSS ever support the css prop like Emotion? For instance:

<div css={{ backgroundColor: "red" }} />

or is the solution here to use the css method? For instance:

<div className={css({ backgroundColor: "red" })} />
oliviertassinari commented 4 weeks ago

@damusnet I doubt it. The sx prop seems to serve the same purpose.

<div sx={{ backgroundColor: "red" }} />

But maybe we would want this, with a deprecation, helping people to migrate from Emotion.

damusnet commented 4 weeks ago

Gotcha, thanks for the quick reply.

I was under the impression that sx was a little different, with support for things like px and py (that's fine), but maybe also stricter requirements (thought I read that border has to be a number, and can't be 1px solid red for instance). If it's a perfect superset, then that's great.

oliviertassinari commented 4 weeks ago

@damusnet The sx prop is meant to be a superset of the css prop. I would expect border: 1px solid red to work.