Skip to content

How to add new prop to ThemeUI components #1071

Answered by hasparus
sadeghbarati asked this question in General
Discussion options

You must be logged in to vote

IMO:

Use composition. Build your own branded components library on top of Theme UI.

So

  1. Import Theme UI Button as ThemeUIButton
  2. Create a new React component Button which accepts additional props, and ThemeUIButton props through rest params. (({ isLoading, ...rest }) => ...)
  3. Handle additional props.
  4. Spread rest onto ThemeUIButton.
    <ThemeUIButton disabled={isLoading} {...rest}>
      {isLoading ? "Loading..." : children}
    <ThemeUIButton>
    

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@sadeghbarati
Comment options

@hasparus
Comment options

@sadeghbarati
Comment options

@sadeghbarati
Comment options

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