Question about scaleToFit behavior
See original GitHub issueHello! I was hoping to use the scaleToFit
option on Text
to shrink the font-size of a number if it was longer than the space available to display it. Unfortunately, it appears that the behavior of scaleToFit
scales the size of the text up as well.
Is there an existing workaround to do what I need via Text
(only shrink the size if it is too long)?
If not, would you be open to a PR that adds this option?
Though, I am not certain the best way to add it. Adding a second prop seems somewhat clunky. Updating the existing prop to have shrink-only
(or something similar) would be more ergonomic, but might be awkward to do in a backward-compatible way.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
ScaleToFit does not work - Stack Overflow
I have problems with the ScaletoFit method. I Have a UIPageViewController ... The question is: Why does the ScaleAspectFit-Method not work?
Read more >Scale to Fit issues with tabs - EFI Communities
There should be 4 images attached to this thread/question. The initial image is simply displaying "scale to fit" has yet to be selected...
Read more >"Scale to fit Paper Size" is not working - Microsoft Community
To answer your question, the scale to fit function is not working. ... Can you replicate this behavior? Any suggestions?
Read more >Dynamic Sizing and Responsiveness for Learnosity Questions
Question Type MināWidth MināHeight
Match List 300px 300px
Multiple Choice Question ā Standard 100px 110px
Multiple Choice Question ā Block UI 100px 130px
Read more >object-fit - CSS: Cascading Style Sheets - MDN Web Docs
The object-fit CSS property sets how the content of a replaced element, such as an or , should be resized to fit its...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If I get time, Iāll make an update to the demo later today. I guess the easiest change would be replacing the checkbox with a dropdown.
Hey @kyythane š thanks for checking out
visx
. I canāt think of a workaround for this at the moment, itās not exposed inText
but you might be able to leverage theuseText
hook directly. It might still be a little bit tricky since this is implemented with a transform, so a PR might be the best way to add it cleanly.Iām definitely happy to review a PR! modifying
shrinkToFit: boolean
to something likeshrinkToFit: boolean | 'shrink-only'
seems like it could be a good approach to me š I agree keeping a single prop sounds good and I donāt think itād be breaking š„ since it would still accepttrue/false
.