Skip to content

How to creating a <Box /> component. #813

Answered by nmn
taylorpreston asked this question in Q&A
Discussion options

You must be logged in to vote

@taylorpreston A generic Box component can be created but what is not supported is the configuration on a per-breakpoint basis.

This often becomes an anti-pattern when trying to implement responsive layouts. Your design system should include a set of "values". Those values should change based on the viewport breakpoints internally. You should not be mixing and matching arbitrary values for different viewport breakpoints when using the Box component.

So, I would recommend something like the following instead:

<Box p="sm_fixed">Hello World</Box>
<Box p="sm"_scaling>Hello World</Box>
function Box({p, ...props}) {
  return <div 
    {...stylex.props(styles.base, paddingStyles[p])}
    {...props}

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@zaydek
Comment options

@nmn
Comment options

nmn Jan 2, 2025
Collaborator

@zaydek
Comment options

@taylorpreston
Comment options

@nmn
Comment options

nmn Jan 3, 2025
Collaborator

Answer selected by nmn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request
3 participants
Converted from issue

This discussion was converted from issue #811 on December 17, 2024 05:49.