Button
Demo
Studio
import { ClassicButton } from 'tuya-panel-style-button';import TuyaRNSvgs from 'tuya-panel-kit/lib/components/iconfont/svg/defaultSvg';<Viewstyle={{display: 'flex',}}><ClassicButtononLongPress={() => console.log('long press')}icon={TuyaRNSvgs.power}text="switch"/><Text style={styles.title}>No icon, no background</Text><View style={{ flexDirection: 'row' }}><ClassicButtonwidth={90}showIcon={false}icon={TuyaRNSvgs.power}text="switch"iconColor="#FFF"padding={[5, 0, 0, 5]}/><ClassicButtonwidth={90}showIconBg={false}icon={TuyaRNSvgs.power}text="switch"iconColor="#158CFC"style={{ marginLeft: 10 }}/></View><Text style={styles.title}>Set padding</Text><ClassicButtonicon={TuyaRNSvgs.power}text="switch"iconColor="#FFF"style={{ marginLeft: 10 }}padding={[10, 40, 0, 0]}/></View>;
Nordic
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" />;
Acrylic
<AcrylicButton icon={TuyaRNSvgs.power} text="switch" iconColor="#FFF" />
API
ClassicButton
Name | Description | Type | Default |
---|---|---|---|
style | Outermost container style | StyleProp | -- |
iconBgStyle | Icon background style | StyleProp | -- |
textStyle | Text style | StyleProp | -- |
activeOpacity | Transparency at touch | number | -- |
text | Button text | string | -- |
disabled | Disable components | boolean | false |
width | Width | number | -- |
padding | [paddingTop, paddingRight, paddingBottom, paddingLeft] | number[] | -- |
radius | Radius | number | -- |
backgroundColor | Component Background color | string | -- |
fontColor | Button text font color | string | (required) |
fontSize | Button text font size | number | (required) |
fontWeight | Button text font weight | "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900" | (required) |
milliseconds | Long press time The unit is in ms | number | 200 |
onPress | Click the button to call back | () => void | -- |
onLongPress | Long press button callback function | () => void | -- |
icon | icon svg path | string | -- |
image | image url,icon has a higher priority | string | -- |
iconSize | icon size | number | cx(24) |
iconBgSize | icon background size | number | cx(50) |
showIcon | Whether to display icon | boolean | true |
showIconBg | Whether to display icon background | boolean | true |
iconColor | icon color | string | #fff |
iconBgColor | icon background color, only rgb、rgba or hex | BackgroundType | #158CFB |
iconBgRadius | icon background radius | number | cx(50) |
imageRadius | image radius | number | 0 |