ButtonCard
Demo
Studio
import { useState } from 'react';import { ClassicButtonCard } from 'tuya-panel-classic-kit';import TuyaRNSvgs from 'tuya-panel-kit/lib/components/iconfont/svg/defaultSvg';const list = [{label: 'Button1',key: '0',disabled: true,},{label: 'Button2',key: '1',},{label: 'Button3',key: '2',},{label: 'Button4',key: '3',},];const list1 = list.map(item => ({...item,icon: TuyaRNSvgs.power,}));function Demo() {const [activeKeys, setActiveKeys] = useState(['0', '1']);const handActiveKeyChange = (key, nextKeys, data) => {setActiveKeys(nextKeys);};return (<View><ClassicButtonCardtitle="Card Title"showIconBg={false}icon={TuyaRNSvgs.power}list={list}defaultActiveKeys={['1']}/><Text style={styles.title}>Controlled multiple selection</Text><ClassicButtonCardtitle="Card Title"icon={TuyaRNSvgs.power}iconSize={14}showIconBgiconBgColor={{deg: 90,stops: {'0%': 'red','100%': 'yellow',},}}list={list}rowCount={4}activeKeys={activeKeys}activeKeyChange={handActiveKeyChange}type="multi"/></View>);}
Nordic
import { NordicButtonCard } from 'tuya-panel-nordic-kit';import { ClassicIconBackground } from 'tuya-panel-style-icon-background';import TuyaRNSvgs from 'tuya-panel-kit/lib/components/iconfont/svg/defaultSvg';function DemoNordic() {const renderButtonItem = data => {// console.log(data);return (<View style={styles.buttonStyle}><ClassicIconBackground showIconBg={false} icon={data.icon} /><Text style={{ marginTop: 15 }}>{data.label}</Text></View>);};return (<View><NordicButtonCardtitle="Card Title"showIconBg={false}icon={TuyaRNSvgs.power}list={list}/><Text style={styles.title}>Custom button rendering methods</Text><NordicButtonCardtitle="Card Title"showIconBg={false}icon={TuyaRNSvgs.power}list={list1}renderButtonItem={renderButtonItem}rowCount={4}showTitle={false}backgroundColor="rgba(255, 255, 255, 0)"/></View>);}
API
ClassicButtonCard
| Name | Description | Type | Default |
|---|---|---|---|
| list | The button data | RangeItem[] | (required) |
| activeKeys | The currently selected Key is passed into the component for control | ActiveKeys | -- |
| defaultActiveKeys | The key selected by default | ActiveKeys | -- |
| activeKeyChange | Select the callback function for key | (key: string, nextKeys: ActiveKeys, data: RangeItem) => void | -- |
| renderButtonItem | Custom button rendering methods | (data: RangeItem) => ReactElement | -- |
| rowCount | Number of buttons per row | number | -- |
| disabled | Disable | boolean | false |
| style | The Outer container Style | StyleProp | -- |
| titleContentStyle | The title container style | StyleProp | -- |
| titleStyle | The title text style | StyleProp | -- |
| buttonStyle | The button container style | StyleProp | -- |
| textStyle | The button text style | StyleProp | -- |
| padding | The content padding [Top, Right, Bottom, Left] | number[] | [cx(24), cx(20), cx(24), cx(20)] |
| width | Width | number | -- |
| backgroundColor | Component background color | string | -- |
| radius | Component radius | number | -- |
| buttonHeight | Button height | number | -- |
| buttonBgColor | Button background color | string | -- |
| buttonBgRadius | Button radius | number | -- |
| buttonFontSize | Button text font sie | number | -- |
| buttonFontColor | Button text font color | string | -- |
| buttonOffset | The distance between the vertical buttons | number | -- |
| buttonFontWeight | The button text font weight | "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900" | normal |
| activeButtonBgColor | Active Button background color | string | -- |
| activeButtonFontSize | Active Button font size | number | -- |
| activeButtonFontColor | Active Button font color | string | -- |
| activeButtonFontWeight | The selected button text font weight | "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900" | normal |
| title | The title | string | -- |
| showTitle | The Show title or not | boolean | true |
| titleFontSize | The title font size | number | -- |
| titleFontColor | The title font color | string | -- |
| titleFontWeight | The title font weight | "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900" | normal |
| icon | icon svg path | string | -- |
| iconSize | icon size | number | cx(24) |
| iconBgSize | icon background size | number | cx(50) |
| 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) |