Skip to content

How to correctly use Styled Function with Predefined jsx patterns #2109

Answered by segunadebayo
JonnyDawe asked this question in Q&A
Discussion options

You must be logged in to vote

Creating a styled component from a pattern is not a valid composition pattern for the compiler. We'll consider adding this to our upcoming ESLint Plugin.

However, I think the component can be greatly simplified to achieve the same result you're looking. Here's another way to design it:

Playground: https://play.panda-css.com/e9h4RvvC1d

const paletteRecipe = cva({
  variants: {
    visual: {
      solid: {
        bg: 'currentColor',
      },
      outline: {
        border: '3px solid currentColor',
      },
    },
  },
  defaultVariants: {
    visual: 'solid',
  },
})

type Props = RecipeVariantProps<typeof paletteRecipe> & {
  color: SystemStyleObject['color']
}

function PaletteCircle(p…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@JonnyDawe
Comment options

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