0

Is it possible to change font size dynamically with Material-UI's Typography element so that the text will fit to the container when the container or typography element has a fixed width?

So like if there was a lot of text in a 120px box, it would shrink the font size to fit it.

cclloyd
  • 8,171
  • 16
  • 57
  • 104
  • I believe this has been answered before - https://stackoverflow.com/questions/16056591/font-scaling-based-on-width-of-container – curiousdev Mar 11 '20 at 21:46

1 Answers1

1

You can calculate letters in box then make some event, if letter > someNumber fire event example :

    ... check isLotfText func
      <Typography
        variant={isLotofText ? 'h3' : 'h6'}
        color='textSecondary'
      />