Radio list
A plain list of four options where you pick one.
A plain list of four options where you pick one.
<!--
From Uiverse.io by cbolson: https://uiverse.io/cbolson/ugly-yak-75
MIT License, Copyright (c) 2023 Uiverse.io. The licence is at the foot of this file: keep it with the code.
Changed for Tastebud: colours moved to the Figma palette.
-->
<form class="my-form">
<div>
<input id="radio-1" type="radio" name="option" />
<label for="radio-1">Radio 1</label>
</div>
<div>
<input checked="" id="radio-2" type="radio" name="option" />
<label for="radio-2">Radio 2</label>
</div>
<div>
<input id="radio-3" type="radio" name="option" />
<label for="radio-3">Radio 3</label>
</div>
<div>
<input id="radio-4" type="radio" name="option" />
<label for="radio-4">Radio 4</label>
</div>
</form>
<style>
/* From Uiverse.io by cbolson - Tags: radio */
.my-form {
--_clr-primary: #666;
--_clr-hover: #d06154;
--_clr-checked: #1b94c6;
}
.my-form > div {
--_clr-current: var(--_clr-primary);
display: flex;
align-items: center;
gap: 0.5rem;
}
.my-form > div + div {
margin-block-start: 0.5rem;
}
.my-form label {
cursor: pointer;
color: var(--_clr-current);
transition: color 150ms ease-in-out;
}
/* styled radio */
.my-form input[type="radio"] {
appearance: none;
outline: none;
width: 1.5rem;
height: 1.5rem;
aspect-ratio: 1;
padding: 0.25rem;
background: transparent;
border: 1px solid var(--_clr-current);
border-radius: 50%;
display: grid;
place-content: center;
cursor: pointer;
position: relative;
}
.my-form input[type="radio"]::after {
content: "";
position: absolute;
inset: 0.25rem;
opacity: 0;
scale: 0;
transition:
opacity 150ms ease-in-out,
scale 150ms ease-in-out;
background-color: var(--_clr-checked);
border-radius: inherit;
}
.my-form label:hover,
.my-form input[type="radio"]:focus-visible,
.my-form input[type="radio"]:focus-visible + label,
.my-form input[type="radio"]:hover,
.my-form input[type="radio"]:hover + label {
--_clr-current: var(--_clr-hover);
}
.my-form input[type="radio"]:focus-visible::after,
.my-form input[type="radio"]:hover::after {
opacity: 0.5;
scale: 1;
background-color: var(--_clr-hover);
}
.my-form input[type="radio"]:checked + label:not(:hover),
.my-form input[type="radio"]:checked:not(:hover) {
--_clr-current: var(--_clr-checked);
}
.my-form input[type="radio"]:checked::after {
opacity: 1;
scale: 1;
}
</style>
<!--
MIT License
Copyright (c) 2023 Uiverse.io
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
Changed for this site: Colours moved to the Figma palette.