Figma flavored squircles for React Native
source link: https://reactnativeexample.com/figma-flavored-squircles-for-react-native/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Figma flavored squircles for React Native
React Native Figma Squircle
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.
Installation
Install react-native-svg
Then install this library:
yarn add react-native-figma-squircle
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',
}}
/>
)
}
You can also use it with MaskedView to apply the squircle shape to an Image
.
import MaskedView from '@react-native-community/masked-view'
function ProfilePicture() {
return (
<MaskedView
style={styles.profilePicture}
maskElement={
<SquircleView
style={StyleSheet.absoluteFill}
squircleParams={{
cornerRadius: 30,
cornerSmoothing: 0.7,
fillColor: 'pink',
}}
/>
}
>
<Image style={StyleSheet.absoluteFill} source={{ uri: 'https://...' }} />
</MaskedView>
)
}
Props
Inherits View Props
squircleProps
An object that controls how the squircle looks.
interface SquircleProps {
cornerRadius: number
cornerSmoothing: number
fillColor?: Color
strokeColor?: Color
strokeWidth?: number
}
cornerSmoothing
number
Goes from 0 to 1, controls how smooth the corners should be.
cornerRadius
number
Similar to borderRadius
in the style
prop.
fillColor
Color
| defaults to#000
Similar to backgroundColor
in the style
prop.
strokeColor
Color
| defaults to#000
Similar to backgroundColor
in the style
prop.
strokeWidth
number
| defaults to0
Similar to borderWidth
in the style
prop.
GitHub
React Native Animated Header with ScrollView
Wallet app for the THORChain community with React-Native
Subscribe to React Native Example for Android and iOS
Get the latest posts delivered right to your inbox
Recommend
-
39
README.md
-
41
README.md
-
64
README.md grip-mode
-
20
XD Pascal for Windows Dedicated to my father Mikhail Tereshkov, who instilled in me a taste for engineering Summa...
-
9
Vim-Flavored-Markdown Add-on to Tim Pope's markdown.vim to highlight using Github Flavored Markdown. a syntax plugin that extends the Tim Pope's markdown syntax...
-
5
Gittub flavored Markdown and pygments highlighting in Jekyll advertisements I've deployed my Jekyll blog on a VPS. I would now like to add Github-f...
-
3
<?xml encoding="utf-8" ??>Introduction Use Vultr Flavored Markdown when writing for the Vultr Docs library. The main features of Vultr Flavored Markdown that vary from other common Markdown flav...
-
16
I tried the pixel-flavored Coke, and it Bytes This one can stay in the metaverse By
-
4
Home ...
-
3
lookout — Microsoft’s web-flavored update for Outlook begins rolling out to more testers Refreshed client is still missing support for IMAP, multiple accounts....
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK