Check if dragging or clicking a control during runtime

With UGUI I would normally do something like this:

public static bool IsMouseOverUIObject ()
{
    if (EventSystem.current != null)
    {
        PointerEventData eventDataCurrentPosition = new PointerEventData (EventSystem.current)
        {
            position = new Vector2 (Input.mousePosition.x, Input.mousePosition.y)
        };

        List<RaycastResult> results = new List<RaycastResult> ();
        EventSystem.current.RaycastAll (eventDataCurrentPosition, results);

        return results.Count > 0;
    }
    else
    {
        Debug.LogError ("No EventSystem present to check for 'InputValidation.IsMouseOverUIObject ()'.");
        return false;
    }
}

To check if the mouse was above some interactable object so that when I dragged a slider, I could stop my camera from spinning.

How would I go about doing this with UIToolkit for runtime?

You can use a state-machine of Events. UI Toolkit calls this a “Manipulator”. Here’s an example that lets you click+drag an element:

The example also captures the mouse so all events while holding down the left button are sent to the same element, even if the mouse is no longer on top of it. If you only care about MouseEnter/MouseLeave (no clicking), then just monitor for those two events on your element and maintain a “mouse is currently over me” variable if needed.