# 为注册按钮添加图标

**URL:** <https://meta.discourse.org/t/add-an-icon-to-the-sign-up-button/121027>\
**Category:** Support\
**Created:** [2019年六月21日 22:09 UTC](https://meta.discourse.org/t/add-an-icon-to-the-sign-up-button/121027 "2019-06-21T22:09:33Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)\
**Post date:** [2019年六月22日 02:36 UTC](https://meta.discourse.org/t/add-an-icon-to-the-sign-up-button/121027/2 "2019-06-22T02:36:53Z")

</div>

Yes, that’s correct — those header buttons are a widget [located here](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/widgets/header.js.es6#L227) (more about widgets: [A tour of how the Widget (Virtual DOM) code in Discourse works](https://meta.discourse.org/t/a-tour-of-how-the-widget-virtual-dom-code-in-discourse-works/40347))

What I’m doing here is reopening the widget, copying the existing widget, and adding the line `icon: user`. You can add this to your theme’s `</head>` section in `admin > customize > themes` (or head\_tag.html if you’re developing a remote theme)

```xml
<script type="text/discourse-plugin" version="0.8.13">
api.reopenWidget("header-buttons", {
      tagName: "span.header-buttons",

  html(attrs) {
    if (this.currentUser) {
      return;
    }

    const buttons = [];

    if (attrs.canSignUp && !attrs.topic) {
      buttons.push(
        this.attach("button", {
          label: "sign_up",
          className: "btn-primary btn-small sign-up-button",
          action: "showCreateAccount",
          icon: "user"
        })
      );
    }

    buttons.push(
      this.attach("button", {
        label: "log_in",
        className: "btn-primary btn-small login-button",
        action: "showLogin",
        icon: "user"
      })
    );
    
    return buttons;
  }
});
</script>

```

---

_[View the full topic](https://meta.discourse.org/t/add-an-icon-to-the-sign-up-button/121027)._
