Button按钮 - 图1

Button 按钮

基本用法

  1. import { Button } from 'zarm';
  2. ReactDOM.render(
  3. <>
  4. <Button>default</Button>
  5. <Button theme="primary">primary</Button>
  6. </>
  7. , mountNode);

块级按钮

  1. import { Button } from 'zarm';
  2. ReactDOM.render(
  3. <>
  4. <Button block>default</Button>
  5. <Button block disabled>default disabled</Button>
  6. <Button block theme="primary">primary</Button>
  7. <Button block disabled theme="primary">primary disabled</Button>
  8. </>
  9. , mountNode);

按钮主题

  1. import { Button } from 'zarm';
  2. ReactDOM.render(
  3. <>
  4. <Button>default</Button>
  5. <Button theme="primary">primary</Button>
  6. <Button theme="danger">danger</Button>
  7. </>
  8. , mountNode);

按钮尺寸

  1. import { Button } from 'zarm';
  2. ReactDOM.render(
  3. <>
  4. <Button size="lg">lg</Button>
  5. <Button>md</Button>
  6. <Button size="sm">sm</Button>
  7. <Button size="xs">xs</Button>
  8. </>
  9. , mountNode);

按钮形状

  1. import { Button, Icon } from 'zarm';
  2. ReactDOM.render(
  3. <>
  4. <Button shape="rect" theme="primary">rect</Button>
  5. <Button theme="primary">radius</Button>
  6. <Button shape="round" theme="primary">round</Button>
  7. <Button shape="circle" theme="primary">circle</Button>
  8. <Button shape="circle" icon={<Icon type="right" />} />
  9. </>
  10. , mountNode);

带阴影

  1. import { Button } from 'zarm';
  2. ReactDOM.render(
  3. <>
  4. <Button shadow>default</Button>
  5. <Button shadow theme="primary">primary</Button>
  6. <Button shadow theme="danger">danger</Button>
  7. </>
  8. , mountNode);

图标按钮

  1. import { Button, Icon } from 'zarm';
  2. ReactDOM.render(
  3. <>
  4. <Button icon={<Icon type="right-round" theme="success" />}>正确</Button>
  5. <Button icon={<Icon type="wrong-round" theme="danger" />}>错误</Button>
  6. <Button loading>加载中</Button>
  7. </>
  8. , mountNode);

链接按钮

  1. import { Button } from 'zarm';
  2. ReactDOM.render(
  3. <>
  4. <Button href="https://zarm.design">default</Button>
  5. <Button theme="primary" href="https://zarm.design">primary</Button>
  6. <Button theme="danger" href="https://zarm.design">danger</Button>
  7. <Button disabled theme="primary" href="https://zarm.design">disabled</Button>
  8. </>
  9. , mountNode);

幽灵按钮

  1. import { Button } from 'zarm';
  2. ReactDOM.render(
  3. <>
  4. <Button block ghost>default</Button>
  5. <Button block ghost theme="primary">primary</Button>
  6. <Button block ghost theme="danger">danger</Button>
  7. <Button block ghost disabled>disabled</Button>
  8. </>
  9. , mountNode);

API

属性类型默认值说明
themestring'default'设置主题,可选值为 defaultprimarydanger
sizestring'md'设置大小,可选值为 mdlgsmxs
shapestring'radius'设置形状,可选值为 rectradiusroundcircle
blockbooleanfalse是否块级元素
ghostbooleanfalse是否幽灵按钮
shadowbooleanfalse是否带阴影
disabledbooleanfalse是否禁用
loadingbooleanfalse是否加载中状态
iconReactNode-设置图标
onClickMouseEventHandler<Element>-点击后触发的回调函数
htmlTypestring'button'设置原生 button 的type值,可选值为buttonsubmitreset
hrefstring-点击跳转的地址,指定此属性button的行为和 a 标签一致
targetstring-规定在何处打开链接文档,相当于 a 标签的target属性,href属性存在时生效
mimeTypestring-链接中指向的文档的 mime 类型,相当于 a 标签的type属性,href属性存在时生效