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 Icon position to the left side

See original GitHub issue

Right now all button icons being shown together with a text on left or right side. Is there any way to make it on left side?

image

I have tried to use iconContainerStyle to make it position absolute but it didn’t do anything.

Thank you

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9

github_iconTop GitHub Comments

20reactions
umair-khanzadacommented, Jun 27, 2019

@iRoachie, Sorry, but I think adding a margin is not a solution. I also come around in the same issue and solve with position have a look at below fix.

containerStyle={{position: 'relative'}}
iconContainerStyle={{position: 'absolute', left: 10}}
6reactions
iRoachiecommented, Apr 9, 2019

Ohh sorry, misread. There’s no way to only move the icon left and not affect other components inside. Button uses flexbox with justify-content: center to align the elements inside the button to the center.

Most you can do is justify-content: space-between or justify-content: flex-start. But this will move both the title and icon.

space-between

<Button
  title="Icon"
  icon={{ name: 'check-circle', color: '#fff' }}
  buttonStyle={{ justifyContent: 'space-between' }}
/>

image

flex-start

<Button
  title="Icon"
  icon={{ name: 'check-circle', color: '#fff' }}
  buttonStyle={{ justifyContent: 'flex-start' }}
/>

image


If your button has a set width you can hack around with the margin.

<Button
  title="Icon"
  icon={{ name: 'check-circle', color: '#fff' }}
  iconContainerStyle={{marginRight: 50 }}
  buttonStyle={{ justifyContent: 'flex-start', width: 200 }}
/>

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap align icon to leftside of button - Stack Overflow
I am trying to Center the text on the button but have the icon aligned to the left side. <button type="button" class="btn btn-default...
Read more >
Alignment to left icons and text in button - Vaadin
I have button with icon and text. If I extend width of button then icon and text is centrally. But I would have...
Read more >
Where to Place Icons Next to Button Labels - UX Movement
Placing them to the left of your button label allows users to see the icon first.
Read more >
Buttons with icons - Leonardo Fernandes
These buttons each have an arrow icon. The next button has an arrow pointing right, aligned to the right of the button.
Read more >
Does the position of icons in buttons affect the user?
For navigation items such as previous and next I would use the icon based on the direction i want to point. (right placed...
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