Last updated
Last updated
It's like but type safe by design.
can often helps when you get red squiggly lines.
If you have your styles defined as a separate function:
Your component can also only have a className
prop (and no classes
).
What's very powerfull about the withStyles API it it's capable to infer the type of the nested overwritable classes, example:
If you want to use withStyles
instead of styled
for the extra type safety it provides:
Before:
After (just wrap everything into root
):
You can also pass a mui component like for example <Button />
and you'll be able to overwrite (it uses the classes
prop).
You can experiment with those examples live , you can also run it locally with .
To ease debugging you can specify a name that will appear in every class names. It is like the .
It's also required to for .