buttons / github-buttons

:octocat: Unofficial github:buttons
https://buttons.github.io
BSD 2-Clause "Simplified" License
1.09k stars 261 forks source link
button component frontend github

github-buttons

build npm

Usage

Use as a Snippet

Get started quickly with github:button configurator.

Use as a Component

Use as a Module

import { render } from 'github-buttons'

// export function render(options: object, callback: (el: HTMLElement) => void): void;
render(options, function (el) {
  document.body.appendChild(el) 
})

// export function render(anchor: HTMLAnchorElement, callback: (el: HTMLElement) => void): void;
render(anchor, function (el) {
  anchor.parentNode.replaceChild(el, anchor)
})

Options

href

Assign href attribute (GitHub link) for button.

title

Assign title attribute for button.

data-icon

Set icon on button. A subset of Octicons is bundled.

data-color-scheme

Define a mapping of system color scheme to widget color scheme in css-like syntax.

This is an opt-in feature since version >=2.3.0. It means if data-color-scheme is undefined, it would still behave like version <2.3.0, where light color scheme is used under all conditions.

Once data-color-scheme is set to a string, it will inherit the default mapping: no-preference: light; light: light; dark: dark;.

User declarations would override the default. For example:

A single word can be used to force the color scheme everywhere since version >=2.11.0. For example:

data-size

Set button size. Possible values are undefined and 'large'.

data-show-count

Show a dynamic count based on button type (detected from href):

Tailing slash, query string, and hash in the href won't affect type detection:

data-text

Set button text. When button is generated from <a> element and data-text is undefined, the button text will be anchor's textContent.

aria-label

Set aira-label for button.


See also


License

See LICENSE.