Full stack developer & undergrad student of Mathematics; very passionate about both. Enthusiastic about learning, teaching, writing, open source, linguistics and more.
Of course, the CLI generalizes this example to any component, and supports Typescript, using a named export (instead of the default export), etc.
Most examples out there used the component-specific variants, such as styled.h1, but to me it felt that the more generic styled(component) are more useful - however if you are using the component-specific variants, do tell!
I use component specific variants quite regularly. Generally, as long as it's a simple component consisting of a single styled element (e.g. a div) I will use the component specific variants as I find them easier to read. However, I work a lot with Material UI and when styling MUI components I use styled(MuiComponent). Do you use the styled(Component) syntax you describe above for consistency or is there another reason?
Full stack developer & undergrad student of Mathematics; very passionate about both. Enthusiastic about learning, teaching, writing, open source, linguistics and more.
I actually have used Material UI a lot as well, and I think I originally tended towards the generic styled(Component) syntax simply because I was used to MUI's way of doing things - where the definition of the styles for a component is closely tied to the component itself (at least that's how it was when MUI still used JSS).
However, I'm realizing more and more how useful and neat the tag-specific variants are! Cheers!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
My implementation, in a simple example, goes something like this:
Of course, the CLI generalizes this example to any component, and supports Typescript, using a named export (instead of the default export), etc.
Most examples out there used the component-specific variants, such as
styled.h1
, but to me it felt that the more genericstyled(component)
are more useful - however if you are using the component-specific variants, do tell!I use component specific variants quite regularly. Generally, as long as it's a simple component consisting of a single styled element (e.g. a div) I will use the component specific variants as I find them easier to read. However, I work a lot with Material UI and when styling MUI components I use styled(MuiComponent). Do you use the styled(Component) syntax you describe above for consistency or is there another reason?
This makes a lot sense!
I actually have used Material UI a lot as well, and I think I originally tended towards the generic
styled(Component)
syntax simply because I was used to MUI's way of doing things - where the definition of the styles for a component is closely tied to the component itself (at least that's how it was when MUI still used JSS).However, I'm realizing more and more how useful and neat the tag-specific variants are! Cheers!