#Extending to Custom Component

7 messages · Page 1 of 1 (latest)

patent pecan
#

Is it possible to create a custom component based off a base component like the following?

components: {
  Button: Button.extend({
    defaultProps: { color: primaryColor },
  }),
  // referring to this part below
  ButtonSecondary: Button.extend({
    defaultProps: { color: secondaryColor },
  }),
},

const ButtonSecondary = (props) => {
  const { color, children } = useProps('ButtonSecondary', null, props);
  return <div style={{ color }}>{children}</div>
}
#

The first one, Button: Button.extend works fine, but I am trying to create a new button that will be used in other places. Is there a different way to set this up? ButtonSecondary is not taking any of the default styles from Button.

tepid crater
patent pecan
#

Like using a color set in the theme provider.

tepid crater
#

What you mean by pass theme variable?

Not just something like this?

const CustomButton = Button.withProps({
  color: 'primary.9',
})