简体   繁体   中英

Turn SVG icon into button

<button className="zapButton"> <Zap /> </button>

The only thing I've been able to find is wrapping the icon in the button tag. The only problem with this is I get a rectangular button and the icon inside the rectangle. What i am trying to figure out is how to make it so that the button is only the SVG icon.

You can add onClick attribute to Zap itself, any element can be clickable, doesn't need to be button. Or you can remove the border from the button you currently have with css border: none to make it look like there's no rectangular button.

<button class="zap-button" style="height: auto; width: auto; border: none;">
  <svg></svg>
</button>

And of course you shouldn't use inline styles.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM