Material-ui: [Chip] Limit text length and truncate it with ellipsis

Created on 8 Jan 2020  路  2Comments  路  Source: mui-org/material-ui


  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Summary 馃挕


The <Chip /> could receive a maxLength property that truncates with ellipsis

Examples 馃寛

<Chip label='My Very Long text that needs to truncate' maxLength={2} />

Renders My...

Motivation 馃敠

Avoids writing string truncate functions outside of this component.

Chip duplicate

Most helpful comment

@felipesilvati The best solution approach current is to apply a max-width CSS property on the chip: https://github.com/mui-org/material-ui/pull/18708

Duplicate of #18587

e.g.

<Chip style={{ maxWidth: 100 }} />

Capture d鈥檈虂cran 2020-01-08 a虁 22 10 15

All 2 comments

@felipesilvati The best solution approach current is to apply a max-width CSS property on the chip: https://github.com/mui-org/material-ui/pull/18708

Duplicate of #18587

e.g.

<Chip style={{ maxWidth: 100 }} />

Capture d鈥檈虂cran 2020-01-08 a虁 22 10 15

It is very good,
But it would be nice if we could add a title

@oliviertassinari How do we add the html title attribute to a chip?
ie:

<Chip title={chipTitle} /> as <div title='allText'>your text</div>

image

Nice! It already exists, thanks!
image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

reflog picture reflog  路  3Comments

mattmiddlesworth picture mattmiddlesworth  路  3Comments

activatedgeek picture activatedgeek  路  3Comments

FranBran picture FranBran  路  3Comments

ryanflorence picture ryanflorence  路  3Comments