How to wrap title on to new line react native

Aidan

I was wondering how to wrap the title on to another line or possibly 2 lines before cutting off... I tried flex wrap but im possibly not applying it correctly. Or if theres some javascript I could add to the ternary. Apologies if this has already been answered I couldnt find it. enter image description here

            <View style={styles.titleWrapper}> 
                <Text style={styles.title}>
                    {title.length > 20 ? title.slice(0, 22) + "..." : title}
                </Text>
                <MaterialIcons name="favorite-border" color="#72bcd4" size={24} />
            </View>
            <View style={styles.descriptionWrapper}>
                <Text style={styles.description}>
                    {description.length > 100 ? description.slice(0, 100) + "..." : description }
                </Text>
            </View>
        </View>
    </TouchableOpacity>

)

const styles = StyleSheet.create({
    card: {
        backgroundColor: "#fff",
        height: 300,
        margin: 20,
        borderRadius: 10,
        shadowColor: "black",
        shadowOpacity: 0.25,
        shadowOffset: {width: 0, height: 2},
        shadowRadius: 8,
        elevation: 5
    },
    imageWrapper: {
        width: "100%",
        height: "60%",
        borderTopLeftRadius: 10,
        borderTopRightRadius: 10,
        overflow: "hidden"
    },
    titleWrapper: {
        height: "10%",
        paddingHorizontal: 15,
        justifyContent: "space-between",
        alignItems: "center",
        flexDirection: "row",
        marginTop: 10
    },
Guruparan Giritharan

You have specify the line count like

<Text style={styles.title} numberOfLines={2}>
                {titile}
            </Text>

React native will handle the ellipsis for you based on the lines

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to remove title from React Native Navigator?

From Dev

How to wrap HTML text in each new line with <li> tag?

From Dev

WPF - how to go to new TextBlock line inside wrap panel?

From Dev

How to wrap a preference title? (Really)

From Dev

How to wrap a preference title? (Really)

From Dev

How to create new line in Plot.ly JS title

From Dev

XSLT String Wrap:How do I wrap words in a String at New line character(\n)

From Dev

How to wrap a line in kotlin?

From Dev

New line in h:ouputtext for title

From Dev

How to set alert box title in React-Native's alert?

From Dev

How do I add custom title and button to a header in React Native?

From Dev

How to monitor changes in webview document title with react native

From Dev

Swift Text Field wrap to new line

From Dev

Wrap text to new line inside table cells

From Dev

EditText - On word wrap (new line) listener

From Dev

Wrap a list to new line in Bootstrap 3

From Dev

Wrap element to new line/row using flexbox

From Dev

span word wrap in ng repeat into new line

From Dev

How to wrap the first word of a title with a span

From Dev

How to wrap the first word of a title with a span

From Dev

How to disable line wrap in a terminal?

From Dev

React Native Grid View: Flexbox wrap not working

From Dev

Wrap fetch API in class method React Native

From Dev

How to wrap two line into single line with delimiter

From Java

How can I insert a line break into a <Text> component in React Native?

From Dev

How to build and deploy a react-native app from command line?

From Dev

In react-native TextInput box show a line, how to removed it

From Dev

How to position the button to be in line with the title?

From Dev

react-native: ListView, how to push new rows from top

Related Related

  1. 1

    How to remove title from React Native Navigator?

  2. 2

    How to wrap HTML text in each new line with <li> tag?

  3. 3

    WPF - how to go to new TextBlock line inside wrap panel?

  4. 4

    How to wrap a preference title? (Really)

  5. 5

    How to wrap a preference title? (Really)

  6. 6

    How to create new line in Plot.ly JS title

  7. 7

    XSLT String Wrap:How do I wrap words in a String at New line character(\n)

  8. 8

    How to wrap a line in kotlin?

  9. 9

    New line in h:ouputtext for title

  10. 10

    How to set alert box title in React-Native's alert?

  11. 11

    How do I add custom title and button to a header in React Native?

  12. 12

    How to monitor changes in webview document title with react native

  13. 13

    Swift Text Field wrap to new line

  14. 14

    Wrap text to new line inside table cells

  15. 15

    EditText - On word wrap (new line) listener

  16. 16

    Wrap a list to new line in Bootstrap 3

  17. 17

    Wrap element to new line/row using flexbox

  18. 18

    span word wrap in ng repeat into new line

  19. 19

    How to wrap the first word of a title with a span

  20. 20

    How to wrap the first word of a title with a span

  21. 21

    How to disable line wrap in a terminal?

  22. 22

    React Native Grid View: Flexbox wrap not working

  23. 23

    Wrap fetch API in class method React Native

  24. 24

    How to wrap two line into single line with delimiter

  25. 25

    How can I insert a line break into a <Text> component in React Native?

  26. 26

    How to build and deploy a react-native app from command line?

  27. 27

    In react-native TextInput box show a line, how to removed it

  28. 28

    How to position the button to be in line with the title?

  29. 29

    react-native: ListView, how to push new rows from top

HotTag

Archive