How can i open an input type color when i press a custom button to get the color value? I want the color-palette button to open the input color and nothing else to show like the green color box.
<div class="color-picker">
<button id="color-palette"><i class='bx bx-palette'></i>
<input type="color" value="#1dbbce" id="colorPicker">
</button>
</div>
Can I do it with only HTML, CSS or I need JavaScript? Thanks.
2
Answers
If you’re wanting to not show the color picker at all until the user clicks on a button, I think this answer is what you’re looking for.
You can associate a label with the color input element and then hide the input. This way when you click the label it will open the color picker.