UNPKG

react-native-glassmorphism

Version:

A React Native component for creating a Glassmorphism effect with background blur.

55 lines (54 loc) 1.93 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const react_1 = __importDefault(require("react")); const react_native_1 = require("react-native"); const blur_1 = require("@react-native-community/blur"); const Glassmorphism = ({ children, width = 10, height = 10, borderRadius, borderWidth = 1, borderColor = 'rgba(255, 255, 255, 0.3)', // Light border blurType = 'light', // Default blur style blurAmount = 20, // Strength of blur effect shadowColor = 'rgba(0, 0, 0, 0.2)', // Soft shadow style = {}, }) => { return (<react_native_1.View style={[styles.container, { width, height, borderRadius }, style]}> {/* Blurred Background Layer */} <blur_1.BlurView style={[styles.blurLayer, { borderRadius }]} blurType={blurType} blurAmount={blurAmount} reducedTransparencyFallbackColor="white"/> {/* Glass Effect Layer */} <react_native_1.View style={[ styles.glassLayer, { width, height, borderRadius, borderWidth, borderColor, shadowColor, }, ]}> {children} </react_native_1.View> </react_native_1.View>); }; const styles = react_native_1.StyleSheet.create({ container: { position: 'relative', overflow: 'hidden', }, blurLayer: { position: 'absolute', width: '100%', height: '100%', top: 0, left: 0, }, glassLayer: { padding: 5, alignItems: 'center', justifyContent: 'center', position: 'absolute', backgroundColor: 'rgba(255, 255, 255, 0.3)', // Transparent background }, }); exports.default = Glassmorphism; //# sourceMappingURL=Glassmorphism.js.map