IconBackground 图标背景

代码演示

背景和图标

import { ClassicIconBackground } from 'tuya-panel-style-icon-background';
<View style={{ display: 'flex', flexDirection: 'row' }}>
<ClassicIconBackground icon={TuyaRNSvgs.power} style={{ marginRight: 20 }} />
<ClassicIconBackground
iconBgColor="#ff6700"
icon={TuyaRNSvgs.power}
iconBgRadius={5}
/>
</View>;

只有图标

import { ClassicIconBackground } from 'tuya-panel-style-icon-background';
<ClassicIconBackground
icon={TuyaRNSvgs.power}
iconColor="#57BCFB"
iconBgRadius={5}
showIconBg={false}
/>;

设置图片

import { ClassicIconBackground } from 'tuya-panel-style-icon-background';
<ClassicIconBackground
image={IMAGE}
iconBgColor="#fff"
iconColor="#57BCFB"
iconBgRadius={5}
imageRadius={10}
/>;

背景渐变

import { ClassicIconBackground } from 'tuya-panel-style-icon-background';
<View style={{ display: 'flex', flexDirection: 'row' }}>
<ClassicIconBackground
iconBgColor={{
deg: 90,
stops: {
'0%': 'red',
'100%': 'yellow',
},
}}
icon={TuyaRNSvgs.power}
style={{ marginRight: 20 }}
/>
<ClassicIconBackground
iconBgColor={{
stops: [
{
offset: '0%',
stopColor: '#ff6700',
stopOpacity: '1',
},
{
offset: '100%',
stopColor: '#22ee2d',
stopOpacity: '1',
},
],
rx: '50%',
ry: '50%',
fx: '50%',
fy: '50%',
cx: '50%',
cy: '50%',
}}
iconSize={40}
iconBgSize={70}
icon={TuyaRNSvgs.power}
style={{ marginRight: 20 }}
/>
</View>;

Background 背景

import { Background } from 'tuya-panel-style-icon-background';
<View>
<Background
style={{ justifyContent: 'center', alignItems: 'center' }}
width={100}
height={100}
background="#ff6700"
>
<Text>hello world</Text>
</Background>
<Background
style={{ justifyContent: 'center', alignItems: 'center', marginTop: 20 }}
width={100}
height={100}
background={IMAGE}
>
<Text style={{ color: '#fff' }}>hello world</Text>
</Background>
<Background
style={{ paddingTop: 20, marginTop: 20 }}
contentStyle={{ paddingLeft: 5 }}
width={100}
height={100}
background={{
deg: 90,
stops: {
'0%': 'red',
'100%': 'yellow',
},
}}
>
<Text style={{ color: '#fff' }}>hello world</Text>
</Background>
<Background
style={{
paddingTop: 20,
marginTop: 20,
borderRadius: 20,
overflow: 'hidden',
}}
contentStyle={{ paddingLeft: 5 }}
width={100}
height={100}
background={{
stops: [
{
offset: '0%',
stopColor: '#ff0',
stopOpacity: '1',
},
{
offset: '100%',
stopColor: '#00f',
stopOpacity: '1',
},
],
rx: '50%',
ry: '50%',
fx: '50%',
fy: '50%',
cx: '50%',
cy: '50%',
}}
>
<Text style={{ color: '#fff' }}>hello world</Text>
</Background>
</View>;

API

ClassicIconBackground

ClassicIconBackground

属性名描述类型默认值
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
style组件容器样式StylePropnull

Background

API

属性名描述类型默认值
background背景 纯颜色、线性渐变或者径向渐变BackgroundType(必选)
width宽度number(必选)
height高度number(必选)
style外层容器样式StyleProp--
contentStyle内容容器样式StyleProp--
tuya07:31