antd Button按钮,自定 type样式
image.pngimage.pngimage.png

  1. const style = { textAlign: 'center', width: 60, fontSize: 12 };
  2. function ButtonStatus({ label, color, icon }) {
  3. return (
  4. <div style={style}>
  5. <Button shape='circle' type={color} icon={icon} className='mb8' />
  6. <p>{label}</p>
  7. </div>
  8. );
  9. }

icon

  1. const ButtonStatus = {
  2. 0: { label: '成功', color: 'success', icon: 'check' },
  3. 1: { label: '失败', color: 'danger', icon: 'close' },
  4. 2: { label: '进行中', color: 'process', icon: 'clock-circle' },
  5. };

less

重写 Button组件的样式,自定义 type类型的 css样式

  1. .ant-btn.ant-btn-process,
  2. .ant-btn.ant-btn-process:hover,
  3. .ant-btn.ant-btn-process:focus {
  4. border-color: #1890ff;
  5. background-color: #1890ff;
  6. color: #fff;
  7. }
  8. .ant-btn.ant-btn-success,
  9. .ant-btn.ant-btn-success:hover,
  10. .ant-btn.ant-btn-success:focus {
  11. border-color: #52c41a;
  12. background-color: #52c41a;
  13. color: #fff;
  14. }