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.

An Icon only button doesn't have a border

See original GitHub issue

Expected Behavior

The <Button> component should have a border if an the icon property is used and the label and children are not present. I would expect the border to be gone only if I have used the plain property.

Actual Behavior

If only the icon property is used, the button will have no border, and the border radius from the theme is not applied. The exception to this is if you use the primary prop as well, which will cause the button to render as expected.

URL, screen shot, or Codepen exhibiting the issue

In the following codepen you can see the various states of an icon-only button. I’ve added a border style to highlight the lack of border radius in the styled component.

https://codesandbox.io/s/x3oz9jp18p

Steps to Reproduce

import React from "react";
import ReactDOM from "react-dom";
import { Grommet, Button } from "grommet";
import { Facebook } from "grommet-icons";

function App() {
  return (
    <Grommet>
      <Button icon={<Facebook />}  />
    </Grommet>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

Your Environment

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
LucianBuzzocommented, Apr 24, 2019

Thanks for the clarification @dallas

TLDR: Setting plain to false explicitly will give an icon-only button padding and a border

<Button icon={<Facebook />} plain={false} />
1reaction
dallascommented, Apr 23, 2019

And here’s a forked version of your Code Sandbox showing the 3 different states as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lightning button icon without border
As sfdcfox already said That border is there to indicate active focus..... but if you still want to remove it assign a class...
Read more >
How to have a css outline on a <button> tag, only by tab, but ...
This is the only way to ensure that the Buttons will always have an outline 'just during focusing on while tabbing' for accessibility,...
Read more >
The Button element - HTML: HyperText Markup Language
Buttons that only show an icon to represent do not have an accessible ... This border is declared through CSS in the browser...
Read more >
lightning-button-icon - documentation - Salesforce Developers
A lightning-button-icon component represents an icon-only button element that executes an action in ... bare displays an icon without a container or border...
Read more >
Button - Grommet
Only relevant for themes that have defined a value for button.default. object. { background: string | object, border: ...
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