![]() I’m also not the biggest fan of setting it over and over on elements, so let’s set a variable we can use later, and then use it to set a global line-height. I’m not the worlds biggest fan of united line-height, but alas, it’s necessary here to do the math. This should be used if there is no left avatar or left icon. A note about overflow-ellipsis, overflow-ellipsis should only be used if the. mdc-typography-overflow-ellipsis, Truncates overflow text to one line. If you set the max-height to 1.4rem * 3, you’ve done it! This can be useful to render an alternative Typography variant by wrapping the children (or primary) text, and optional secondary text with the Typography component. Material Designs text sizes and styles were developed to balance content. Material Designs text sizes and styles were developed to balance content density. And I need to write text in card that match exactly 2 lines. Imagine an element has a line-height of 1.4rem and you want to make sure it only shows a maximum of three lines of text. For a reactjs app, I use Material-ui ( for the design. I first saw this trick on the now-dead Mobify blog, and more recently covered by Natalia Onischuk on Hacking UI. ![]() Context menu Here is an example of a context menu. You can use the Typography component with noWrap to workaround this issue: A short message A very long text that overflows A very long text that overflows Change transition Use a different transition. We somehow failed to cover it properly in our canonical post on line clamping, so I’ll cover it here then add it to that post. There is a flexbox bug that prevents text-overflow: ellipsis from working in a flexbox layout. There is another way though, which is very clever and something I’d call a bonafide CSS trick. It’s gotten a little easier lately since Firefox (since version 68) has started supporting the ultra-bizarre -webkit-line-clamp soup method, which makes browser support for that pretty OK. ![]() Using just CSS (no JavaScript or server-side dancing) is nice for the simplicity. ![]() Includes support for some of the more common values, as well as some extras for controlling display when printing. Truncating multiple lines is a bit harder. Display - Material-UI Display Quickly and responsively toggle the display value of components and more with the display utilities. Truncating a single line of text if is fairly straightforward. The trick in this article is still pretty neat and clever, but there is a now-standardized way to do this which is probably your best bet. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |