Socket
Socket
Sign inDemoInstall

react-native-svg

Package Overview
Dependencies
Maintainers
4
Versions
242
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-svg

SVG library for react-native


Version published
Weekly downloads
1.1M
increased by7.32%
Maintainers
4
Weekly downloads
 
Created

What is react-native-svg?

The react-native-svg package allows React Native developers to render SVG images within their mobile applications. It provides a set of SVG primitives that work in a similar way to the standard React Native components. With react-native-svg, you can create complex shapes, paths, and graphics that are scalable without losing quality, which is essential for responsive design.

What are react-native-svg's main functionalities?

Drawing basic shapes

This code sample demonstrates how to draw a basic circle shape with a green fill and a blue stroke.

{"<Svg height=\"100\" width=\"100\"><Circle cx=\"50\" cy=\"50\" r=\"45\" stroke=\"blue\" strokeWidth=\"2.5\" fill=\"green\"/></Svg>"}

Creating paths

This code sample shows how to create a path using the 'Path' component, which allows for more complex shapes and lines.

{"<Svg height=\"100\" width=\"100\"><Path d=\"M40 60 A 10 10 0 0 0 60 60\" fill=\"none\" stroke=\"black\"/></Svg>"}

Applying gradients

This code sample illustrates how to apply a linear gradient to an ellipse shape.

{"<Svg height=\"100\" width=\"100\"><Defs><LinearGradient id=\"grad\" x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"0%\"><Stop offset=\"0%\" stopColor=\"rgb(255,255,0)\" stopOpacity=\"0\" /><Stop offset=\"100%\" stopColor=\"rgb(255,0,0)\" stopOpacity=\"1\" /></LinearGradient></Defs><Ellipse cx=\"50\" cy=\"50\" rx=\"50\" ry=\"20\" fill=\"url(#grad)\"/></Svg>"}

Text rendering

This code sample shows how to render text within an SVG using the 'Text' component.

{"<Svg height=\"100\" width=\"100\"><Text x=\"50\" y=\"50\" textAnchor=\"middle\" fill=\"purple\">SVG Text</Text></Svg>"}

Other packages similar to react-native-svg

Keywords

FAQs

Package last updated on 16 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc