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.

Second array value skipped with responsive styling + custom breakpoints

See original GitHub issue

🐛 Bug report

When using custom breakpoints, adding responsive styling with array syntax skips the second value.

💥 Steps to reproduce

  1. Add custom breakpoints to theme.ts.
  2. Go to any component and use array syntax for responsive styling. Eg. bg={["tomato", "green", "blue", "yellow"]}.
  3. You will notice the second value of the array "green" is never applied.

💻 Link to reproduction

CodeSandbox reproduction: https://codesandbox.io/s/kind-thunder-khlbw?file=/src/index.js

🧐 Expected behavior

All array values should be incrementally applied.

bg={["tomato", "green", "blue", "yellow"]}

tomato - base green - sm blue - md yellow -lg

🌍 System information

Software Version(s)
Chakra UI 1.6.3
Browser Chrome
Operating System Ubuntu 16.04

📝 Additional information

Link to discussions #4178

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
spidertwin2commented, Jun 28, 2021

Thanks @jatin33 for taking the time to find a workaround this! It had me bumfuzzled since forever!

🦕

1reaction
jatin33commented, Jun 27, 2021

@spidertwin2 Have you tried using “em” or “rem” instead of “px” as css unit to create custom breakpoints? I tried and it seems to be working. working sandbox url: https://codesandbox.io/s/exciting-jepsen-gvlou?file=/src/theme.ts @with-heart Is this expected or we can treat it as a bug? or we can add something to mention about this in documentation Loom Video: https://www.loom.com/share/e83c44c9633647f8a1e32a0044242568

Read more comments on GitHub >

github_iconTop Results From Across the Web

Skipping values while using responsive style props #4178
It is strange that the second array value is skipped with custom breakpoints.
Read more >
4 Patterns for Responsive Props in React - DEV Community ‍ ‍
Responsive Prop Patterns. The foundation of responsive props in react is knowing whether a given media query (aka breakpoint) is active. Let's ...
Read more >
Breakpoints - Material UI - MUI
API that enables the use of breakpoints in a wide variety of contexts.
Read more >
Responsive Styles - Chakra UI
All style props accept arrays as values for mobile-first responsive styles. ... To skip certain breakpoints, you can pass null to any position...
Read more >
Building Responsive Apps with Base Web
Tips and tricks for building responsive apps for mobile and desktop using Base Web.
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