<button onclick="getColor()">カラーピッカーを起動する</button>
<p id="Color"/>
if (window.EyeDropper == undefined) {
    console.error('EyeDropper API is not supported on this platform');
  Color='EyeDropper API is not supported on this platform'
}
const eyeDropper = new EyeDropper();

async function getColor(){
  const color=await eyeDropper.open()
  console.log(color)
  Color.innerText=color.sRGBHex
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.