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)
更多angular1/2/4/5、ionic1/2/3、react、vue、微信小程式、nodejs等技術文章、視訊教程和開源專案,請關注微信公眾號——全棧弄潮兒。