Custom Rendering for Dictionary Values

I have a @dataclass which has a Dict[str,int] field, for which I’d like to display the integer value has hexadecimal.

How can I do this in a reusable way?

Not sure if this is a Python or a Rich/Textual question. In Python, I would use an f-string:

In [1]: value = 42                                                                                                                                                                                          

In [2]: f"0x{value:04X}"                                                                                                                                                                                    
Out[2]: '0x002A'

There is no hook in Rich for this. You could make a custom class extended from int, which has a custom repr.