0.3.2 • Published 2 years ago

react-native-squircle-skia v0.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-squircle-skia

thumbnail

Disclaimer

@shopify/react-native-skia is alpha release. Use with caution.

This library dependes on figma's blog article.

What is this?

This library creates a smooth cornered rectangle view via skia path based on Figma's corner smoothing.

Installation

follow installation guide in @shopify/react-native-skia

then using yarn,

  yarn add react-native-squircle-skia

or

  npm install react-native-squircle-skia --save

Usage

basic usage

import React, { useState } from 'react';
import { SafeAreaView, StyleSheet, Text } from 'react-native';
import Squircle from 'react-native-squircle-skia';

const App = () => {
  const [radius, setRadius] = useState(50);

  return (
    <SafeAreaView style={styles.container}>
      <Squircle
        smoothing={0.7}
        style={[
          styles.squircle,
          {
            borderRadius: radius,
          },
        ]}
      >
        <Text>i am a child</Text>
      </Squircle>
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  squircle: {
    width: '100%',
    aspectRatio: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: 'red',
  },
});

export default App;

Props

Squircle inherits View Props in order to use all the styles presetted in your own project.

  • This library uses borderRadius(including all the others like borderTopLeftRadius) to set corner radius.
  • This library uses backgroundColor to set the path fill

squircleParams

smoothing

number | defaults to 1

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

color

SquircleColorProp

Is used to set backgroundColor(path fill color). you can use a skia ColorProp. backgroundColor in style prop will be ignored if you set color.

TODO

  • borderWidth | borderColor | borderStyle support for Squircle.

Thanks to

Motivated by

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.12

2 years ago

0.2.11

2 years ago

0.2.10

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago