按钮组件。
import React, {Component} from 'react';
import {Button} from 'hana-ui';
/**
* @en
* Base
*
* Base usage.
*
* @cn
* 基础
*
* 基础用法。
*/
export default class ExampleBase extends Component {
render() {
const baseStyle = {marginRight: 10};
return (
<div>
<Button style={baseStyle} size={'large'}>(ง •̀_•́)</Button>
<Button style={baseStyle} type={'primary'}>(ง •̀_•́)</Button>
<Button style={baseStyle} size={'small'} type={'error'}>(ง •̀_•́)</Button>
</div>
);
}
}
基础用法。
import React, {Component} from 'react';
import {Button} from 'hana-ui';
/**
* @en
* Group
*
* Button could has an icon at the front.
*
* @cn
* 成组
*
* 可以在按钮的开头放一个图标。
*/
export default class ExampleIcon extends Component {
render() {
const baseStyle = {marginRight: 10};
return (
<div>
<Button
style={baseStyle}
icon={'hana'}
iconColor={'black'}
>
wow
</Button>
<Button
type={'primary'}
style={baseStyle}
icon={'hana'}
iconColor={'white'}
/>
</div>
);
}
}
可以在按钮的开头放一个图标。
import React, {Component} from 'react';
import {Button} from 'hana-ui';
/**
* @en
* Label
*
* Button component can set a label to show data after button.
*
* @cn
* 标记
*
* 也可以将一些Label放在标记后面。
*
*/
export default class ExampleLabel extends Component {
render() {
return (
<div>
<Button
label={'( /) V (\\ )'}
icon={'hana'}
iconColor={'white'}
style={{marginRight: 10}}
/>
<Button
label={'( /) V (\\ )'}
labelPosition={'right'}
icon={'hana'}
iconColor={'white'}
/>
</div>
);
}
}
也可以将一些Label放在标记后面。
import React, {Component} from 'react';
import {ButtonGroup, Button} from 'hana-ui';
/**
* @en
* Group
*
* Multiple buttons could be added to a group.
*
* @cn
* 成组
*
* 多个按钮可以归于一组。
*/
export default class ExampleGroup extends Component {
render() {
return (
<ButtonGroup>
<Button>
Group 1
</Button>
<Button
htmlType={'submit'}
type={'primary'}
icon={'hana'}
iconColor={'white'}
/>
<Button
type={'disabled'}
icon={'hana'}
iconColor={'white'}
>
Group 3
</Button>
<Button>
Group 4
</Button>
</ButtonGroup>
);
}
}
多个按钮可以归于一组。
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
style | object | 自定义组件样式 | |
size | enum: 'large' 'middle' 'small' |
'middle' | 设置按钮大小,可选配置为: 'large','middle','small' |
type | enum: 'primary' 'error' 'default' 'disabled' 'warning' |
'default' | 设置按钮类型,可选配置:'primary','error','default','disabled' |
htmlType | string | 'button' | 按钮type 类型 |
label | string | 按钮label,默认显示在按钮左边 | |
labelPosition | enum: 'left' 'right' |
指定按钮label 位置,默认值为'left' | |
icon | string | 按钮图标 | |
iconColor | string | 设置按钮图标颜色 | |
iconStyle | object | 自定义按钮图标的样式 | |
iconSize | string | 设置按钮图标大小 | |
className | string | 设置组件class name | |
onClick | function | 自定义按钮点击事件 | |
children | node | 设置按钮组件的子组件 |
未在文档中说明的属性将会被自动加到根元素或form元素上。
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
style | object | 自定义组件样式 | |
className | string | 自定义组件class name | |
children | node | 设置组件的子组件 |
未在文档中说明的属性将会被自动加到根元素或form元素上。