question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Button(Props): Make the icon prop more intuitive and dynamic

See original GitHub issue

Description The icon position props come with a huge surface area. The idea is to decrease the APIs surface area by introducing more functionalities.

Proposed Change Instead of iconRight and default left position of the icon, we can introduce a new prop called iconPosition. And the usage looks might look something like this ⬇️

iconPosition: = "left" | "right" | "top" | "bottom"

The following functionality can be achieved by using the flex container for the text and the icon and changing it’s the direction to row | row-reverse | column | column-reverse to achieve all the possible combinations.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
laxmycommented, Sep 26, 2020

Hi @pranshuchittora , Can I take this up?

1reaction
flyingcirclecommented, Sep 20, 2020

I wonder if it might be simpler to or possible to have button follow the same general pattern as Card and ListItem have now. Something like:

<Button>
  <Button.Icon />
  <Button.Title />
</Button>

This leaves greater flexibility and customization for users without having to sacrifice ease of use. And it also helps prevent prop bloat.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Button Component and Props - Build a web app with React ...
Create a reusable button component and receive React props.
Read more >
How To Customize React Components with Props
In this tutorial, you'll create custom components by passing props to your component. Props are arguments that you provide to a JSX element....
Read more >
Create a highly reusable button with styled-system and styled ...
Today we are going to create our own cool reusable button component . ... we add styled-system we can create even more...
Read more >
Passing icons as props in a consistent way using React
1. Unify your icon API · 2. Build the component that accepts dynamic icons · 3. Passing icons to our new component.
Read more >
How to Overload TypeScript React Component Interfaces by ...
This article explains how to create correct, intuitive APIs for React components in TypeScript by using prop values to overload React components.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found