0.3.1 • Published 5 months ago

@react-native-masked-view/masked-view v0.3.1

Weekly downloads
1,106
License
MIT
Repository
github
Last release
5 months ago

React Native MaskedView

Build Status Version MIT License Lean Core Badge

Provides a React component that renders a masked view.

Platforms Supported

  • iOS
  • Android
  • Web

Getting Started

yarn add @react-native-masked-view/masked-view

or

npm install --save @react-native-masked-view/masked-view

Using React Native >= 0.60

Linking the package manually is not required anymore with Autolinking.

Remember to install the pod with:

npx pod-install

Using React Native < 0.60

You then need to link the native parts of the library for the platforms you are using. The easiest way to link the library is using the CLI tool by running this command from the root of your project:

react-native link @react-native-masked-view/masked-view

Usage

Import the MaskedView component from @react-native-masked-view/masked-view and use it like so:

import React from 'react';
import { Text, View } from 'react-native';
import MaskedView from '@react-native-masked-view/masked-view';

const App = () => {
  return (
    <MaskedView
      style={{ flex: 1, flexDirection: 'row', height: '100%' }}
      maskElement={
        <View
          style={{
            // Transparent background because mask is based off alpha channel.
            backgroundColor: 'transparent',
            flex: 1,
            justifyContent: 'center',
            alignItems: 'center',
          }}
        >
          <Text
            style={{
              fontSize: 60,
              color: 'black',
              fontWeight: 'bold',
            }}
          >
            Basic Mask
          </Text>
        </View>
      }
    >
      {/* Shows behind the mask, you can put anything here, such as an image */}
      <View style={{ flex: 1, height: '100%', backgroundColor: '#324376' }} />
      <View style={{ flex: 1, height: '100%', backgroundColor: '#F5DD90' }} />
      <View style={{ flex: 1, height: '100%', backgroundColor: '#F76C5E' }} />
      <View style={{ flex: 1, height: '100%', backgroundColor: '#e1e1e1' }} />
    </MaskedView>
  );
}

export default App

The following image demonstrates that you can put almost anything behind the mask. The three examples shown are masked <View>, <Text>, and <Image>.

Props

Reference

maskElement

TypeRequired
elementYes

androidRenderingMode

By default hardware rendering mode will be used for best performance, however if you need to animate your maskElement then you’ll need to switch to software to get your mask to update. This prop only affects Android.

TypeRequiredDefault
software, hardwareNohardware
expo-bare-templatejitsi-meet-rnreact-native-jitsi-meet-lib@onejs-dev/onenative@infinitebrahmanuniverse/nolb-_react-nrn-tnb-fk-mobile@wavemaker/app-rn-runtime@plasmatictechnologies/alana-react-native-ui-components@everything-registry/sub-chunk-766test-b2c-goodtest-b2c-goodb2ctest-b2c-nice@faceki/blaze-react-native@faceki/react-native-sdkzigvy-expo-templatevih-messenger2universal-gradient-text@hosseinmd/client@harrysong/router-rndigimonk_native_clirn-bij-ui-kitrne-atrytssafecam-360-rnsafecam-components-rnrntypescriptboilerplatern-try-n-buy-abfrlrnshellskeleton-loading-teststepup_jitsi_clubstepup_jitsi_rn@lananhxcnm130/lananh-async-storage@kafudev/react-native-core@kafudev/react-native-shellvih-messenger@onejs-dev/componentsbonuz-ui-expo@create-luna-app/expochatscreen@browntreebear/reactnativeshareduinow-ui-react-nativemaet-expo-templateanother-react-native-skeleton-loaderctc-mobile-design-systemcode-vortexdemopackage_x_y_zreact-native-4tek-component-kitreact-native-animated-masked-linear-gradientreact-native-masked-skeletonreact-native-base-typescript-hungtruongreact-native-nativebase-bottom-tabs-templatereact-native-matirial-ui-v2react-native-gaugereact-native-button-toggle-groupreact-native-checkbox-x-y-zreact-native-gradient-iconreact-native-code-testreact-native-draggable-itemreact-native-expo-router-templatereact-native-expo-managed-templatereact-native-code-bonuz-uireact-native-code-bonuz-ui-nabeelreact-native-skeleton-loadingreact-native-template-coopertemplatereact-native-template-outqourcereact-native-vih-messengersreact-native-typescript-boilerplatereact-native-typescript-zustand-boilerplate@rtarojs/router-rn@s20.ai/safecam-360-rn@react-native-oh-tpl/masked-view@react-native-school/expo-template@react-native-school/expo-typescript-template@pawans/htms@pelerin.tech/textexpo-skeletonexpo-skeleton-loading@vnxjs/router-rnipanel-rntv-core@jakeortega/react-native-button-toggle-group@mainamiru/expo-app-with-navigationdsaas-react-native-demoeduardo-muchak-rneduardo-muchak-components@valkdigital/ui-kit@tarojs/router-rn@sphereon/ui-components.ssi-react-nativedrssr@seraosbolt/tamagui@rn-punikit/basekage-react-native-sdr
0.3.1

5 months ago

0.3.0

7 months ago

0.2.9

1 year ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago