Reusable Components: Button
See original GitHub issueIssue
Description
We need to create a reusable Button
component. We should also be able to define children with any content. The button should receive two properties, onClick
and theme
.
<Button onClick={onClick}>Test</Button>
<Button onClick={onClick} theme="primary">
<Image src={image} />
<span>Some Text</span>
</Button>
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How to Build Reusable Components with Props in React
Let's demonstrate how props are helpful with a final example – but this time around, we'll create a reusable button with the help...
Read more >Reusable Button component example in react js - CodeSandbox
Reusable Button component example in react js. 0. Embed Fork Create Sandbox Sign in. Sandbox Info ... Components. App.js. index.js. styles.css. package.json.
Read more >Creating a reusable Button component with React and Tailwind
This tutorial covers the process of creating a reusable Button component with TailwindCSS and React.
Read more >Building reusable components using React - ButterCMS
As you can now see, you have made a pretty reusable React Button component. You can use the same idea to build a...
Read more >BigBinary Books - Reusable components
In React, a reusable component is a piece of UI that can be used in various parts of an application to build more...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
And instead of onPress I would suggest onClick event. This is a more generic event. This is helpful whenever we have to use cloneElement to clone some component/node
React.cloneElement(component, { onClick: this.handleClick })
we can use generic onClick instead of onPress as it will work for both<Button />
and<button></button>
Something like this -
@crysfel Instead should we have a generic button component which does
This way we neednt have a label prop, the children can be text, image, span, loader whatever? what say?