@primer/g-octicon

1.1.1 • Public • Published

<g-octicon>

This is a custom element that renders SVG Octicons on your page at runtime.

Installation

If you're using npm, install it with:

npm i --save @primer/g-octicon

Otherwise, you can grab the browser bundle from:

https://unpkg.com/@primer/g-octicon

Usage

Add one or more <g-octicon> elements to your HTML:

<g-octicon icon="logo-github" aria-label="GitHub"></g-octicon>

You can create <g-octicon> elements in JavaScript, too:

const alert = document.createElement('g-octicon')
alert.setAttribute('icon', 'alert')

// setting innerHTML will work, too
document.getElementById('icon').innerHTML = `
  <g-octicon icon="alert"></g-octicon>
`

Attributes

The following attributes are observed, and will cause the icon to re-render when changed:

  • icon is the name of the Octicon, e.g. alert or beaker
  • width sets the width of the icon in pixels and scales the height proportionally
  • height sets the height of the icon in pixels and sets the width proportionally

You need only provide width or height. Providing both will produce unwanted vertical or horizontal whitespace around the icon.

License

MIT © GitHub

Readme

Keywords

Package Sidebar

Install

npm i @primer/g-octicon

Weekly Downloads

74

Version

1.1.1

License

MIT

Unpacked Size

134 kB

Total Files

9

Last publish

Collaborators

  • lukasoppermann
  • joshblack
  • siddharthkp
  • camertron
  • hectahertz
  • broccolini
  • jonrohan
  • joelhawksley
  • primer-css
  • colebemis
  • manuelpuyol
  • smockle
  • simurai
  • khiga8