TMPRO: How to make textbox same width as the actual text?

Hi all,
I just have a quick question: So right now, when a player is given some choice options, I want it to make it so that the button’s red highlight (which is just a UI button with a highlight color) is the same WIDTH as the text itself. So ideally, the button would dynamically change its width to the width of the text. So the red highlight would end right at where the text ends at the word “choices,” rather than extending all the way towards the end of the choice panel

I made a quick mock (in paint lol) of what I want to achieve if I didn’t explain it well: The button’s highlight ends where the text ends. Is it possible to dynamically change the width like that?


I currently have a vertical layout group on my choice panel, and the buttons are dynamically generated from a prefab, so if there are four choices, the choice panel will have 4 buttons vertically laid out properly, or if there are two, it will look like the above screenshot.


Fixed the problem: created onselect event trigger on button, disabled the button onselect options, created a quick script for highlighing the text with , and on deselect, deleting the in the text.