Skip to content

How to use named space values with breakpoints? #2344

Answered by hasparus
fwextensions asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @fwextensions! Thanks for the issue.

Responsive tuples can be passed in sx prop when defining styles, but not when defining the theme, because the theme allows arrays as nested scales, and it's not possible to discern between them.

{
  colors: {
    gray: ['#111', '#333', '#aaa', '#eee'] // here a scale with gray.0, gray.1, gray.2, and gray.3
  },
  space: {
    sm: ['1rem', '2rem'] // here, a responsive tuple... or a scale with sm.0, and sm.1 design tokens?
  }
}

If you're sure you'll always want to use a value like this you can export it use it when defining styles.

export const Space = {
  sm: ["1rem", "2rem"],
  md: ["2rem", "3rem"],
};

<div sx={{ p: Space.sm }} />

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@fwextensions
Comment options

@hasparus
Comment options

@fwextensions
Comment options

@hasparus
Comment options

@lachlanjc
Comment options

Answer selected by fwextensions
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants