question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document theme properties' default values

See original GitHub issue

Describe the bug I noticed that if I omit some keys from the theme object I pass to the ThemeProvider, such as breakpoints and fontSizes, some default values will be used, and I couldn’t find that documented anywhere so I don’t think it’s by design. The default values for these two keys are the same as in the base preset, but I can confirm that it’s not the whole base preset, as fonts and fontWeights behave as expected, for example. Could it have something to do with the fact that breakpoints and fontSizes are arrays? What’s especially strange is that I can’t find the default values in the theme returned by the useTheme hook; they only pop up when I try to use them (e.g. fontSize: 1, or any value set to an array will flip at 40em, then 52em, etc.).

To Reproduce

  1. Leave out the breakpoints and fontSizes keys from your theme.
  2. Render <div sx={{ fontSize: 1 }} />
  3. Notice the rendered CSS is font-size: 14px.

Expected behavior I would’ve expected the rendered CSS to be font-size: 1px, which is the case when the theme has a fontSizes key set to an empty array.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lachlanjccommented, Dec 1, 2021

Hmm, I’m of two minds there. I think it makes sense for fontSize & space since those are visible. But having some default breakpoints doesn’t seem so bad? Setting them up is a bit of a pain & there are real scenarios where you don’t need to customize those. But could definitely be convinced otherwise.

1reaction
lachlanjccommented, Nov 30, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Change the default settings for new documents
You can change the default settings for new documents by making changes to the Normal template that new documents are based on. You...
Read more >
Theme Properties
The following table documents the available properties, their default value, and their effect. Property Key. Description. Default Value ...
Read more >
Does createMuiTheme provide default values for missing ...
When looking at the default theme, I'm missing a lot of properties like breakpoints , direction , shadows , spacing , and etc....
Read more >
Resetting theme attributes to default values
To reset any changed attribute value in the Theme Editor to its default value: Select the item in the tree pane that you...
Read more >
Default theme - Material UI
Here's what the theme object looks like with the default values.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found