npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

m-btn

v1.0.13

Published

easy to use library for customisable buttons

Readme

Easy to use and hightly customisable button made with styled-components :nail_care:

yarn add m-btn

npm StackShare

User Guide

Usage

Basic

import React from 'react'
import Mbtn from 'm-btn'

export const (props) => (
	<div>
  		<Mbtn success light content='Save'/>
  		<Mbtn danger light content='Cancel'/>
  	</div>
)

Set Background Color

In order for the shadows to match the background set the color of the background with the method setBackgroundColor() and pass the context.

Set the color of the background with setBackgroundColor().

setBackgroundColor() accept two arguments:

  • color
  • nuance
setBackgroundColor(color, nuance)

and return and object :

bg = {
  color: nuancedColor,
  shadow: {
    light: shadowColorLight,
    dark: shadowColorDark
  }
}
Pass the context

Pass the bg object as the context

const bg = setBackground('grey', 'lighter')

const backgroundColor = bg.color

Content.childContextTypes = {
  bg: PropTypes.object
}

For more information on context see the React docs

Properties

| Name | Type | Default | Description | | :--------- | ---------------- | --------------------- | ---------------------------------------- | | content | PropTypes.string | | Button content | | icon | PropTypes.bool | | Change button content to icon content | | iconClass | PropTypes.string | 'material-icons' | Icon class (ex: 'fa fa-hand-peace-o') | | | | | | | primary | PropTypes.bool | | color | | info | PropTypes.bool | | color | | warning | PropTypes.bool | | color | | success | PropTypes.bool | | color | | danger | PropTypes.bool | | color | | grey | PropTypes.bool | true | color | | | | | | | lighter | PropTypes.bool | | nuance | | light | PropTypes.bool | | nuance | | main | PropTypes.bool | true | nuance | | dark | PropTypes.bool | | nuance | | darker | PropTypes.bool | | nuance | | | | | | | accent | PropTypes.string | | only light, main and dark nuances | | | | | | | bold | PropTypes.bool | | bold font | | textColor | PropTypes.string | backgroundColor | text color (choose between colors or css colors) | | textNuance | PropTypes.string | backgroundColorNuance | text color nuance ( if textColor, choose between nuances) |

Configuration

Change default configurations in m-btn/config directory:

  • Color Palette

  • Style config

  • Background config

Accessing default values

You can import the settings and use those value when you need

import { palette } from 'm-btn'

const color = palette.primary.light

Setting values

| Name | Type | Exemple | Choices | | ------------- | ---------------- | ---------------------------------------- | ------------------------- | | palette | PropTypes.object | const color = palette.primary.main | Colors | | | | | | | fontSize | PropTypes.object | const myFontSize = fontSize.heading2 | Font Sizes (px) | | fontSizeValue | PropTypes.object | const myFontSize =`${fontSizeValue.bodyBig}px` | Font Sizes (num) | | | | | | | spacing | PropTypes.object | const mySpace = spacing.small | Sizes | | diametre | PropTypes.object | const mySpace = spacing.small | Sizes (no huge or tiny) | | baseRadius | PropTypes.string | const myRadius = baseRadius | | | | | | | | setBackground | PropTypes.func | const bg = setBackground('primary', 'light') | | | | | | |

Choices

| Colors | Nuances | Font Sizes | Sizes | | ------- | ------- | ----------- | ----- | | primary | main | heading1 | base | | info | light | heading2 | small | | warning | lighter | heading3 | big | | success | dark | heading4 | tiny | | danger | darker | bodyHuge | huge | | grey | | bodyBig | | | | | body | | | | | bodySmall | | | | | bodyTiny | | | | | rem.Sizes | |

Exemple

import React, { Component } from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import Mbtn, { setBackground, fontSize, palette } from 'm-btn'

const bg = setBackground('grey', 'lighter')

const Wrapper = styled.div`
  background-color: ${bg.color};
  font-size: ${fontSize.bodyBig};
  color: ${palette.info.light};
`

export default class Content extends Component {

  getChildContext () {
    return { bg: bg }
  }

  render () {
    return (
      <Wrapper>
      	<p>I love Styled Components</p>
        <Mbtn
          primary
          bold
          content='hello' />
        <Mbtn
          icon
          info
          accent
          textColor='info'
          textNuance='dark'
          content='query_builder'
        />
        <Mbtn
          icon
          color='#4dd0e1'
          textColor='PaleVioletRed'
          content='lock_open'
        />
        <Mbtn
        icon
        warning
        dark
        iconClass='fa fa-facebook' />
      </Wrapper>
    )
  }

}

Content.childContextTypes = {
  bg: PropTypes.object
}

Easy Start

  1. Create React App
  2. Add Mbtn to package.json
  3. Add icons cdn
  4. Replace App.js
  5. Start your App

Create React App

If you d'ont have create-react-app installed globaly go ahead an install it :

npm install -g create-react-app
Quick Overview
cd my-projects
create-react-app my-app
cd my-app/
npm start

For more info see the docs

Add Mbtn to package.json

npm i m-btn --save

or

yarn add m-btn

Add icons cdn

Add Material Icons cdn in public/index.html:

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

if you want to use FontAwesome or an other icon provider you have to add their cdn too.

Replace App.js

Remove what's in App.js, copy and paste the code below in App.js

import React, { Component } from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import Mbtn, { setBackground, fontSize, palette } from 'm-btn'

const bg = setBackground('grey', 'lighter')

const Wrapper = styled.div`
  background-color: ${bg.color};
  color: ${palette.info.light};
  font-size: ${fontSize.bodyBig};
  text-align: center;
  min-height: 100vh;
  display: flex;
  padding: 4rem;
  flex-direction: column;
  align-items: center;
`

export default class Content extends Component {

  getChildContext () {
    return { bg: bg }
  }

  render () {
    return (
      <Wrapper>
      	<p>I love &lt;Mbtn /&gt; and Styled Components</p>
        <Mbtn
          primary
          bold
          content='Hello' />
        <Mbtn
          icon
          info
          accent
          textColor='info'
          textNuance='dark'
          content='favorite'
        />
      </Wrapper>
    )
  }

}

Content.childContextTypes = {
  bg: PropTypes.object
}
Start your App

If it's not already running start your app:

npm Start