Is it possible to extend components with variants? #74
-
Hey @cschroeter ! I need to extend some of the components of park-ui/ark and I'd love to know the best/recommended way. For example, I want to add a variant like "status" on the Input component to handle form error states. Or a loading state for the Button component, this kind of thing. My first thought was to create an Input wrapper component that applies different styles to and renders it, but it doesn't feel right. So I'd love to know what's the park-ui recommended way of doing this |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
That are useful additions to Park / Ark UI and we have both For the Input state I would recommend using build in conditions like import { defineRecipe } from '@pandacss/dev'
export const input = defineRecipe({
className: 'input',
base: {},
defaultVariants: {
size: 'md',
variant: 'outline',
},
variants: {
outline: {
base: {
_invalid: {
borderColor: 'border.danger',
boxShadow: 'danger',
},
},
},
},
}) For the button it kinda depends how a loading state should look like. If you only require css you can use the same technique - maybe like |
Beta Was this translation helpful? Give feedback.
@kaumac
That are useful additions to Park / Ark UI and we have both
FormControl
and loadings states on the roadmap.How ever you can defintively start ahead.
For the Input state I would recommend using build in conditions like
invalid
to get the job done. The input recipe could look something like this:For the button it kinda depends how a loa…