GithubHelp home page GithubHelp logo

phamfoo / react-native-figma-squircle Goto Github PK

View Code? Open in Web Editor NEW
311.0 3.0 15.0 666 KB

Figma-flavored squircles for React Native

License: MIT License

Shell 0.79% TypeScript 82.73% JavaScript 16.48%
react react-native expo figma squircle

react-native-figma-squircle's Introduction

React Native Figma Squircle

Stable Release license

Figma-flavored squircles for React Native

Disclaimer

This library is not an official product from the Figma team and does not guarantee to produce the same results as you would get in Figma.

What is this?

Figma has a great feature called corner smoothing, allowing you to create rounded shapes with a seamless continuous curve (squircles).

This library helps you bring those squircles to your React Native apps.

Before you install

This library is a very light abstraction on top of figma-squircle. We also depend on react-native-svg to draw the SVG background. In many cases, it's a better idea to just use figma-squircle directly:

  • You can use react-native-skia instead of react-native-svg.
  • More control and flexibility. For example, clipping can be done very easily using Clip Path.

Installation

Install react-native-svg

Then install this library:

yarn add react-native-figma-squircle

or

npm install react-native-figma-squircle

Usage

A SquircleView can be used just like a normal View, except the background is rendered separately from the view background. So to change how it looks, you'll have to use the squircleParams prop instead of the style prop.

import { SquircleView } from 'react-native-figma-squircle'

function PinkSquircle() {
  return (
    <SquircleView
      style={{ width: 200, height: 200 }}
      squircleParams={{
        cornerSmoothing: 0.7,
        cornerRadius: 30,
        fillColor: 'pink',
      }}
    />
  )
}

Props

Inherits View Props

squircleParams

cornerSmoothing

number | Required

Goes from 0 to 1, controls how smooth the corners should be.

cornerRadius

number | defaults to 0

topLeftCornerRadius

number

topRightCornerRadius

number

bottomRightCornerRadius

number

bottomLeftCornerRadius

number

fillColor

Color | defaults to #000

Similar to backgroundColor in the style prop.

strokeColor

Color | defaults to #000

Similar to borderColor in the style prop.

strokeWidth

number | defaults to 0

Similar to borderWidth in the style prop.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.