React-native-paper: TextInput multiline is always vertical padded

Created on 10 Apr 2020  路  5Comments  路  Source: callstack/react-native-paper

TextInput multiline is always vertical padded

Is there a way to prevent the vertical paddings for TextInputs multiline? I'm currently fixed to v3.6.0 since I require ellipsis for Card titles and it seems that for multiline TextInputs the content is always padded.

Screen Shot 2020-04-10 at 11 25 22 AM

Not sure if this is intended. Or how do I prevent this behavior?

question

Most helpful comment

@raajnadar It didn't work for me. I end up using the render prop

<TextInput
    {...props}
    style={styles.field}
    render={(innerProps) => (
    <NativeTextInput
        {...innerProps}
        style={[
        innerProps.style,
        props.multiline
            ? {
                paddingTop: 8,
                paddingBottom: 8,
                height: 100,
            }
            : null,
        ]}
    />
    )}
/>

All 5 comments

Try adding this to style to TextInput component textAlignVertical: 'top'

@raajnadar It didn't work for me. I end up using the render prop

<TextInput
    {...props}
    style={styles.field}
    render={(innerProps) => (
    <NativeTextInput
        {...innerProps}
        style={[
        innerProps.style,
        props.multiline
            ? {
                paddingTop: 8,
                paddingBottom: 8,
                height: 100,
            }
            : null,
        ]}
    />
    )}
/>

@raajnadar It didn't work for me. I end up using the render prop

<TextInput
    {...props}
    style={styles.field}
    render={(innerProps) => (
    <NativeTextInput
        {...innerProps}
        style={[
        innerProps.style,
        props.multiline
            ? {
                paddingTop: 8,
                paddingBottom: 8,
                height: 100,
            }
            : null,
        ]}
    />
    )}
/>

What is component here?

What is the component here?

@anshumanworks Hey! The component is actually the Native Text Input that you can import from the React Native Library.

Try adding this import to your code
import { TextInput as NativeTextInput } from 'react-native';

He imports it under another name to avoid conflict between the native text input and the paper text input.

Hope I helped!

Hi, I had the same issue and using render method also fix my issue. but don't use innerProps.style for styling, and use your own styles. and it will be solved your issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sritharanpalani picture sritharanpalani  路  4Comments

tonyxiao picture tonyxiao  路  3Comments

mihaidaviddev picture mihaidaviddev  路  3Comments

ferrannp picture ferrannp  路  4Comments

zxccvvv picture zxccvvv  路  4Comments