Skip to content

How to reuse duplicate styles from variants? #1100

Answered by jxnblk
mrlubos asked this question in General
Discussion options

You must be logged in to vote

Should I perhaps create one common variant and then extend it from individual components?

Not the only way, and this example maybe isn't the best, but you can inherit variants from other variants:

variants: {
  textBase: {
    color: 'text',
  },
  body: {
    variant: 'variants.textBase',
    padding: 0,
  },
  text: {
    variant: 'variants.textBase',
    padding: 3,
  },
}

Hopefully we'll have support for merging multiple variants together in the sx prop land before v1, which would offer another approach

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mrlubos
Comment options

@jxnblk
Comment options

@mrlubos
Comment options

Answer selected by mrlubos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants