question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Ellipsis to Text

See original GitHub issue

Is your feature request related to a problem? Please describe. I’m looking to add ellipses to my text rendering. It looks like pdfkit handles this, but react-pdf uses a custom layout engine that (from what I can tell) does not call out to pdfkit.

Is this a feature that react-pdf could support? I started digging in a little, but couldn’t really find where to get started.

Describe the solution you’d like An API that would be nice for this use case would be to handle it in the stylesheet ie:

const styles = StyleSheet.create({
  myText: {
    textWrap: 'nowrap',
    textOverflow: 'ellipsis'
  }
})

Describe alternatives you’ve considered I suppose this could also be done as a prop on the Text component as well, but this seems a styling concern.

Alternatively, would it be possible to use pdfkit for an alternative Text layout? (for example, SimpleText or something along those lines). I’m assuming react-pdf is not using pdfkit because the layout there is not powerful enough, or not compatible with yoga.

Additional context

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
si-le-maocommented, Jul 29, 2021

I have a trick for this by using height property

<View style={{ display: 'flex', flexDirection: 'row', height: 10 }}>
    <View style={{ flex: 1 }}>
        <Text>NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN</Text>
    </View>
</View>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Truncate String with Ellipsis - CSS-Tricks
Hey – would anyone know how to do this with a full word? I've seen text-overflow:ellipsis-word used a couple times but haven't been...
Read more >
text-overflow - CSS: Cascading Style Sheets - MDN Web Docs
The text-overflow CSS property sets how hidden overflow content is signaled to users. It can be clipped, display an ellipsis ('…
Read more >
How to implement single-line ellipsis with CSS - Stack Overflow
1 Answer 1 · I have a link <a>, I put the code on the link that wraps in a responsive design and...
Read more >
CSS text-overflow property - W3Schools
The text-overflow property specifies how overflowed content that is not displayed should be signaled to the user. It can be clipped, display an...
Read more >
2 Simple ways you can truncate text using CSS - Kritika's Blog
1) Truncate a single line text using ellipsis · the element must have. width , max-width or flex-basis(if using flex) · the element...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found