Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Styling complex components #1883

Open
makeupsomething opened this issue Mar 22, 2021 · 1 comment
Open

Styling complex components #1883

makeupsomething opened this issue Mar 22, 2021 · 1 comment
Labels

Comments

@makeupsomething
Copy link

makeupsomething commented Mar 22, 2021

Hi all 馃憢

Im not sure how to properly style a button component with multiple sizes and colors. For example I have a theme object with something like this structure.

buttons: {
  primary: {
	  backgroundColor: 'primary',
          // more styles
  },
  secondary: {
	  backgroundColor: 'secondary',
           // more styles
  },
  textButton: {
      small: {
          // more styles
      },
      big: {
         // more styles
      }
    },
  iconButton: {
    small: {
        // more styles
    },
    big: {
       // more styles
    }
  }
}

Using reflexbox how could I define a small textButton with primary coloring?

<Box
	as="button"
	ref={ref}
	onClick={onClick}
	__tx="buttons"
	variant="textButton.small" //want to add a color here too
	sx={{}}
	{...rest}
>

So far I can only get a small textButton or primary colors? I can set buttons.primary as a variant inside small, but then would I need to do that separately for every color, size and button type separately?

@makeupsomething
Copy link
Author

My solution was to override the variant()function in reflex box to handle an array of variants and merge the objects from the theme. It ends up working something like this

<Box
	as="button"
	ref={ref}
	onClick={onClick}
	__tx="buttons"
	variant=["textButton.small", "primary"]
	sx={{}}
	{...rest}
>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant