Open this example in the interactive library
Live preview
Source code
// components/CoordinatePrecisionSlider.tsx
import { useState } from "react";
export default function CoordinatePrecisionSlider({
lat = 43.65,
lon = -79.38,
}: { lat?: number; lon?: number } = {}) {
const [places, set] = useState(3);
return (
<label>
Decimal places
<input
type="range"
max={6}
value={places}
onChange={(e) => set(+e.target.value)}
/>
<output>
{lat.toFixed(places)}, {lon.toFixed(places)}
</output>
</label>
);
}
