Button 按钮

代码演示

Studio 风格

import { ClassicButton } from 'tuya-panel-style-button';
import TuyaRNSvgs from 'tuya-panel-kit/lib/components/iconfont/svg/defaultSvg';
<View
style={{
display: 'flex',
}}
>
<ClassicButton
onLongPress={() => console.log('long press')}
icon={TuyaRNSvgs.power}
text="switch"
/>
<Text style={styles.title}>没有图标、没有背景</Text>
<View style={{ flexDirection: 'row' }}>
<ClassicButton
width={90}
showIcon={false}
icon={TuyaRNSvgs.power}
text="switch"
iconColor="#FFF"
padding={[5, 0, 0, 5]}
/>
<ClassicButton
width={90}
showIconBg={false}
icon={TuyaRNSvgs.power}
text="switch"
iconColor="#158CFC"
style={{ marginLeft: 10 }}
/>
</View>
<Text style={styles.title}>设置内边距</Text>
<ClassicButton
icon={TuyaRNSvgs.power}
text="switch"
iconColor="#FFF"
style={{ marginLeft: 10 }}
padding={[10, 40, 0, 0]}
/>
</View>;

北欧风格

import { NordicButton } from 'tuya-panel-style-button';
import TuyaRNSvgs from 'tuya-panel-kit/lib/components/iconfont/svg/defaultSvg';
<NordicButton icon={TuyaRNSvgs.power} text="switch" iconColor="#FFF" />;

亚克力风格

<AcrylicButton
icon={TuyaRNSvgs.power}
text="switch"
iconColor="#FFF"
isSupportAcrylic={isShow}
/>

API

ClassicButton

属性名描述类型默认值
style最外层容器样式StyleProp--
iconBgStyle图标背景样式StyleProp--
textStyle文字样式StyleProp--
activeOpacity触摸时的透明度number--
text按钮文字string--
disabled禁用组件booleanfalse
width宽度number--
padding最外层容器内边距,格式为 [paddingTop, paddingRight, paddingBottom, paddingLeft]number[]--
radius圆角number--
backgroundColor组件背景颜色string--
fontColor按钮文字颜色string(必选)
fontSize按钮文字大小number(必选)
fontWeight按钮文字字重"normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900"(必选)
milliseconds规定长安的时间 单位为 msnumber200
onPress点击按钮回调函数() => void--
onLongPress长按按钮回调函速() => void--
icon图标 svg pathstring--
image图片地址,图标的优先级更高string--
iconSize图标尺寸numbercx(24)
iconBgSize组件背景尺寸numbercx(50)
showIcon是否显示图标booleantrue
showIconBg是否显示图标背景booleantrue
iconColor图标颜色string#fff
iconBgColor图标背景颜色 只能设置 rgb、rgba 或者 hexBackgroundType#158CFB
iconBgRadius图标背景圆角numbercx(50)
imageRadius图片圆角number0
tuya07:31