Giter Site home page Giter Site logo

badgen

npm version Coverage Status Bundle size License

Fast handcraft svg badge generator. Used on badgen.net.

  • 🌀 Zero dependency
  • ⚡️ Fast by design (see benchmarks)
  • 👯‍ Running in node & browser

Usage

npm install badgen

const { badgen } = require('badgen')

// only `status` is required.
const svgString = badgen({
  label: 'npm',      // <Text>
  labelColor: 'ADF', // <Color RGB> or <Color Name> (default: '555')
  status: 'v1.2.3',  // <Text>, required
  color: 'blue',     // <Color RGB> or <Color Name> (default: 'blue')
  style: 'flat',     // 'flat' or 'classic' (default: 'classic')
  icon: 'data:image/svg+xml;base64,...', // Use icon (default: undefined)
  iconWidth: 13,     // Set this if icon is not square (default: 13)
  scale: 1           // Set badge scale (default: 1)
})

Available color names:

In browser

<script src="https://unpkg.com/badgen"></script>
<script>
  var svgString = badgen({ /*...*/ })
</script>

Benchmarks

npm run bench on iMac 5K (Late 2014), 3.5G i5, with Node.js 12.11.0:

[classic] style, long params x 985,898 ops/sec ±0.37% (94 runs sampled)
[classic] style, full params x 1,284,886 ops/sec ±0.42% (95 runs sampled)
[classic] style, with emoji  x 1,291,768 ops/sec ±0.28% (95 runs sampled)
[classic] style, with icon   x 1,177,120 ops/sec ±0.94% (95 runs sampled)
   [flat] style, long params x 780,504 ops/sec ±0.39% (94 runs sampled)
   [flat] style, full params x 1,012,111 ops/sec ±0.40% (97 runs sampled)
   [flat] style, with emoji  x 1,013,695 ops/sec ±0.91% (95 runs sampled)
   [flat] style, with icon   x 994,481 ops/sec ±0.30% (94 runs sampled)

See Also

Badgen's Projects

badgen icon badgen

Fast handcraft svg badge generator.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.