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>
<ClassicButtonCard
title="Card Title"
showIconBg={false}
icon={TuyaRNSvgs.power}
list={list}
defaultActiveKeys={['1']}
/>
<Text style={styles.title}>Controlled multiple selection</Text>
<ClassicButtonCard
title="Card Title"
icon={TuyaRNSvgs.power}
iconSize={14}
showIconBg
iconBgColor={{
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>
<NordicButtonCard
title="Card Title"
showIconBg={false}
icon={TuyaRNSvgs.power}
list={list}
/>
<Text style={styles.title}>Custom button rendering methods</Text>
<NordicButtonCard
title="Card Title"
showIconBg={false}
icon={TuyaRNSvgs.power}
list={list1}
renderButtonItem={renderButtonItem}
rowCount={4}
showTitle={false}
backgroundColor="rgba(255, 255, 255, 0)"
/>
</View>
);
}

API

ClassicButtonCard

NameDescriptionTypeDefault
listThe button dataRangeItem[](required)
activeKeysThe currently selected Key is passed into the component for controlActiveKeys--
defaultActiveKeysThe key selected by defaultActiveKeys--
activeKeyChangeSelect the callback function for key(key: string, nextKeys: ActiveKeys, data: RangeItem) => void--
renderButtonItemCustom button rendering methods(data: RangeItem) => ReactElement>--
rowCountNumber of buttons per rownumber--
disabledDisablebooleanfalse
styleThe Outer container StyleStyleProp--
titleContentStyleThe title container styleStyleProp--
titleStyleThe title text styleStyleProp--
buttonStyleThe button container styleStyleProp--
textStyleThe button text styleStyleProp--
paddingThe content padding [Top, Right, Bottom, Left]number[][cx(24), cx(20), cx(24), cx(20)]
widthWidthnumber--
backgroundColorComponent background colorstring--
radiusComponent radiusnumber--
buttonHeightButton heightnumber--
buttonBgColorButton background colorstring--
buttonBgRadiusButton radiusnumber--
buttonFontSizeButton text font sienumber--
buttonFontColorButton text font colorstring--
buttonOffsetThe distance between the vertical buttonsnumber--
buttonFontWeightThe button text font weight"normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900"normal
activeButtonBgColorActive Button background colorstring--
activeButtonFontSizeActive Button font sizenumber--
activeButtonFontColorActive Button font colorstring--
activeButtonFontWeightThe selected button text font weight"normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900"normal
titleThe titlestring--
showTitleThe Show title or notbooleantrue
titleFontSizeThe title font sizenumber--
titleFontColorThe title font colorstring--
titleFontWeightThe title font weight"normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900"normal
iconicon svg pathstring--
iconSizeicon sizenumbercx(24)
iconBgSizeicon background sizenumbercx(50)
showIconBgWhether to display icon backgroundbooleantrue
iconColoricon colorstring#fff
iconBgColoricon background color, only rgb、rgba or hexBackgroundType#158CFB
iconBgRadiusicon background radiusnumbercx(50)
tuya07:31