Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native TextInput box-shadow

I want to apply a shadow on TextInput, as shown here: enter image description here

I am making this style, using shadow, and elevation for android:

shadowColor: colors.shadowColor,
    shadowOpacity: 0.5,
    shadowRadius: 3,
    shadowOffset: {
      height: 0,
      width: 0,
    },
    elevation: 2,

However, the result is not as expected. So, I am asking if there's a way to enhance it without passing by a 3rd party package. enter image description here

like image 328
ketimaBU Avatar asked Dec 16 '18 10:12

ketimaBU


1 Answers

I ended up using the react-native-cardview package, results are much better, however, it is so limited, that I can't set the shadow color and other options.

import React, { Component } from 'react';
import {
  View,
  ScrollView,
  TextInput,
} from 'react-native';
import CardView from 'react-native-cardview';
import styles from './styles';

export default class Signup extends Component {

  render() {
    return (
      <View style={{ flex: 1, backgroundColor: colors.whiteColor }}>
        <ScrollView contentContainerStyle={styles.signupContainer}>
            <View style={styles.signupInputs}>
              <CardView
                style={styles.cardStyle}
                cardElevation={2}
                cardMaxElevation={2}
                cornerRadius={5}
              >
                <TextInput
                  underlineColorAndroid="transparent"
                  style={[styles.signupInput, styles.commonsignupStyle]}
                  placeholder="Nom *"
                  placeholderTextColor={colors.primaryColor}
                />
              </CardView>
              <CardView
                style={styles.cardStyle}
                cardElevation={2}
                cardMaxElevation={2}
                cornerRadius={5}
              >
                <TextInput
                  underlineColorAndroid="transparent"
                  style={[styles.signupInput, styles.commonsignupStyle]}
                  placeholder="Prénom *"
                  placeholderTextColor={colors.primaryColor}
                />
              </CardView>
            </View>
        </ScrollView>
      </View>
    );
  }
}

enter image description here

like image 78
ketimaBU Avatar answered Dec 20 '22 00:12

ketimaBU