Have you looked at the sample for the Measurement widget? The Measurement widget really is just a way to wrap the distance and area measurement widgets into one widget. You do need to build the button UI yourself, the sample there is a distance, area, and clear button. On the button click event is when you would set the active tool. The sample is geared toward an app where you can switch between 2D and 3D, since it sounds. like you are just working in 2D, I simplified it below.
Though if you are just looking to have a distance measurement and no area measurement, you're good just using the DistanceMeasurement2D widget.
distanceButton.addEventListener("click", () => {
distanceMeasurement();
});
function distanceMeasurement() {
measurement.activeTool = "distance";
distanceButton.classList.add("active");
areaButton.classList.remove("active");
}