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.

<b-table> Truncate text with ellipsis alternatively instead of text-wrap

See original GitHub issue

Is your feature request related to a problem? Please describe…

When b-tables width gets crunched together the text wraps into new lines. In cases where there is no much horizontal space left this isn´t ideal and sometimes looks a bit weird.

Describe the solution you’d like

I would like the text inside b-table cells to be truncated with an ellipsis like the following if it does not fit in one row:

This text fits This text is to long and…

Additional context

I got the idea from @alexsasharegan tweet on twitter.

Issue Analytics

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

github_iconTop GitHub Comments

6reactions
MRVDHcommented, Nov 30, 2020

@ddweber @tmorehouse I ran into the same issue and simply fixed it by adding this css:

td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 1px;
}

The max-width: 1px; does the trick here. Maybe this could be added to the documentation?

2reactions
tmorehousecommented, May 28, 2019

I was able to get tet to truncate using the fixed table prop, and then using an item scoped slot:

<b-table fixed :items="items" :fields="fields" ....>
  <template slot="someField" slot-scope="{ value }">
    <div class="w-100 text-truncate">{{ value }}</div>
  </template>
</b-table>

Where the someField value is a very long text string.

Unfortunately the fixed prop of table makes each column roughly equal width.

I tried playing with the colgroup width method and couldn’t get it working (although the colgroup slot was working)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to wrap or truncate long strings in a Material-UI ...
noWrap: If true, the text will not wrap, but instead will truncate with a text overflow ellipsis. Note that text overflow can only...
Read more >
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 >
How To Fix Text-Overflow Ellipsis Not Working - Semicolon.dev
A common way to solve ellipsis not working in a table cell is by wrapping cell's content in another HTML element like span,...
Read more >
How To Make CSS Ellipsis Work on a Table Cell - W3docs
This tutorial will help you to make CSS ellipsis work on a table cell. To achieve this goal, you can use some CSS...
Read more >
Text Wrapping for Long Strings in Text Tables - Knowledge Base
How to enable text wrapping for long String fields in a text table in Tableau ... but my long strings are getting truncated...
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