Skip to content

Multi line truncate #1826

Answered by estevanmaito
viperfx asked this question in Help
May 26, 2020 · 5 comments · 1 reply
Discussion options

You must be logged in to vote

If you want to truncate just one line: https://tailwindcss.com/docs/word-break/#truncate

For multi line, there's a plugin for it https://github.com/jhta/tailwindcss-truncate-multiline

But it depends on line-clamp, which is an unofficial API https://caniuse.com/#feat=css-line-clamp

Apart from that, there are hacks:

.truncate-2-lines {
  max-height: 3.6em; /* double the size of line-height */
  line-height: 1.8em;
  display: block;
  text-overflow: ellipsis;
  word-wrap: break-word;
  overflow: hidden;
}

The only way to do using Tailwind, that I know, would be extending with plugins: adding more max-height and leading utilities, etc...

Replies: 5 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@simonswiss
Comment options

Answer selected by simonswiss
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
7 participants