react实现一个button组件

npm地址

github地址


About

a sweet button component of react

技术栈

react + sass + classnames + webpack

Install

npm i react-sweet-button -S
复制代码

Usage

import { SweetButton, DimensionButton } from 'react-sweet-button';
复制代码
  • SweetButton
<SweetButton className="m-t" type="light" size="xlarge" onClick={()=>{alert('我是超大按钮')}}>
  xlarge
</SweetButton>
<SweetButton className="m-l" type="primary" size="large">
  large
</Sweet
<SweetButton className="m-l" type="secondary" size="medium" outline>
  medium
</SweetButton>
<SweetButton className="m-l" type="danger" size="small" outline>
   small
</SweetButton>
<SweetButton className="m-l" type="dark" size="xsmall">
   xsmall
</SweetButton>
<SweetButton size="large" block>
  block button
</SweetButton>
复制代码
  • DimensionButton
<DimensionButton className="m-t" type="light" size="xlarge" onClick={()=>{alert('我是超大按钮')}}>
  xlarge
</DimensionButton>
<DimensionButton className="m-l" type="primary" size="large">
  large
</DimensionButton>
<DimensionButton className="m-l" type="secondary" size="medium">
   medium
</DimensionButton>
<DimensionButton className="m-l" type="danger" size="small">
   small
</DimensionButton>
<DimensionButton className="m-l" type="dark" size="xsmall">
   xsmall
</DimensionButton>
复制代码

效果预览

API

通过设置 Button 的属性来产生不同的按钮样式,推荐顺序为:type -> size -> outline(仅适用于SweetButton) ->block(仅适用于SweetButton)

按钮的属性说明如下:

  • type: 设置按钮类型,可选值为 light primary secondary danger dark或者不设 默认值为 primary

  • size: 设置按钮大小,可选值为 xlarge large medium small xsmall或者不设 默认值large

  • outline: 设置按钮样式(仅带边框按钮)

  • block: 设置按钮样式(block button)


开源组件github地址

更多angular1/2/4/5、ionic1/2/3、react、vue、微信小程序、nodejs等技术文章、视频教程和开源项目,请关注微信公众号——全栈弄潮儿

前端最火框架排行榜——小程序二维码

转载于:https://juejin.im/post/5c2ef12be51d45524b029226

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值