Choice Group Component
A CSS implementation of the Sprout choice-group component.
Example
html
<div class="spr-choice-group">
<div class="spr-choice-button spr-choice-button-open spr-choice-button-active" tabindex="0" role="button">
<div class="spr-choice-button-header">
<span>Yes, I would like to do the thing</span>
</div>
<div class="spr-choice-button-content">
<div class="spr-stack-container-md">
<p>The thing is very important and you should do it.</p>
<p>But you don't have to if you don't want to, you have options.</p>
</div>
</div>
</div>
<div class="spr-choice-button spr-choice-button-closed" tabindex="0" role="button">
<div class="spr-choice-button-header">
<span>No, I do not like the thing</span>
</div>
<div class="spr-choice-button-content" style="height: 0; visibility: hidden; opacity: 0; overflow: hidden;">
<p>This won't be visible in the example so it doesn't matter</p>
</div>
</div>
<div class="spr-choice-button spr-choice-button-closed" tabindex="0" role="button">
<div class="spr-choice-button-header">
<span>I don't know enough about the thing</span>
</div>
<div class="spr-choice-button-content" style="height: 0; visibility: hidden; opacity: 0; overflow: hidden;">
<p>This won't be visible in the example so it doesn't matter</p>
</div>
</div>
</div>
<style>p { margin: 0 }</style>
Compiled CSS
Example
scss
@import 'components/choice-group';
css
compiled
@keyframes openPopover {
from {
transform: scale(0.9);
}
to {
transform: scale(1);
}
}
.spr-icon-rotate-90 {
transform: rotate(90deg);
}
.spr-icon-rotate-180 {
transform: rotate(180deg);
}
.spr-icon-rotate-270 {
transform: rotate(270deg);
}
.spr-choice-group {
display: flex;
flex-direction: column;
}
.spr-choice-group > :not(:last-child) {
margin-bottom: 1rem;
}
.spr-choice-button {
padding: 1rem 1rem;
box-sizing: border-box;
border: 1px solid #e4e5e7;
border-radius: 0.25rem;
background-color: #fff;
cursor: pointer;
}
.spr-choice-button:focus:not(:focus-visible) {
outline: none;
box-shadow: none;
}
.spr-choice-button:focus-visible {
box-shadow: 0 0 0 0.25rem rgba(32, 136, 58, 0.35);
outline: none;
}
@media only screen and (min-width: 56.25rem) {
.spr-choice-button {
padding: 1.5rem 1.5rem;
}
}
.spr-choice-button.spr-choice-button-active {
box-sizing: border-box;
border: 2px solid #20883a;
border-radius: 0.25rem;
}
.spr-choice-button-open .spr-choice-button-content {
margin-top: 1rem;
}
.spr-choice-button-header {
font-family: "AvenirNext", "Helvetica Neue", Arial, sans-serif;
font-size: 16px;
line-height: 1.375rem;
letter-spacing: 0;
font-weight: 400;
line-height: 1;
font-weight: 600;
}