import React from 'react';
import { View } from 'react-native';
import Svg, { Circle, Rect } from 'react-native-svg';
import { cssInterop } from 'nativewind';
// Map className to style and specific native props
cssInterop(Svg, {
className: {
target: "style",
nativeStyleToProp: { width: true, height: true }
},
});
cssInterop(Circle, {
className: {
target: "style",
nativeStyleToProp: { width: true, height: true, stroke: true, strokeWidth: true, fill: true }
},
});
cssInterop(Rect, {
className: {
target: "style",
nativeStyleToProp: { width: true, height: true, stroke: true, strokeWidth: true, fill: true }
},
});
export function SvgExample () {
return (
<View className="inset-0 items-center content-center">
<Svg className="h-1/2 w-1/2" viewBox="0 0 100 100" >
{/* stroke-2 applies the stroke width */}
<Circle cx="50" cy="50" r="45" className="stroke-blue-500 stroke-2 fill-green-500" />
<Rect x="15" y="15" className="w-16 h-16 stroke-red-500 stroke-2 fill-yellow-500" />
</Svg>
</View>
);
}