How do I raycast to UI?

So I have UI buttons that have a 2d box collider on them, and I want to raycast them.

Now I know I could use MouseDown for it, but i’m programing for a touch controller where I need to have the control of what layers do I raycast to etc…

Unity UI has a Graphics Raycaster module which has blocking objects n masks

https://docs.unity3d.com/Manual/script-GraphicRaycaster.html