Hi guys,
I am using custom CSS on choice component where I have made it look like a button.
In Choice component when I click the option again it deselects itself meaning selection state toggles bu changing colour.
I want to be able to do the same with button as well, When I click again button should change colour to de selected state
Chat GPT says I will need to use JS to make this happen. But I cant use it as Glide allows only CSS code in css component
This is my CSS code
/* Center the container horizontally on all screen sizes */
.container {
display: flex;
justify-content: center; /* Center the entire container horizontally */
padding: 0;
height: 100vh; /* Full height of the viewport */
box-sizing: border-box; /* Include padding and border in element's total width and height */
width: 100%;
}
/* Task priority view styling */
.taskpriority-view {
display: flex;
justify-content: center; /* Center the items horizontally */
flex-wrap: wrap; /* Allow wrapping on smaller screens */
list-style: none;
padding: 0;
margin: 0 auto; /* Center the entire task priority view horizontally */
max-width: 1200px; /* Optionally limit the max width for larger screens */
width: 100%;
}
/* Styling for each list item */
.taskpriority-view li {
border-radius: 10px;
flex-grow: 1;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
border: none;
background-color: #d6dbe0; /* Light gray color for deselected state */
color: #314664; /* Dark blue-gray for text color */
width: calc(33.33% - 20px); /* Adjust the width for 3 buttons per row */
margin: 10px; /* Provide equal margin around the items */
padding: 15px; /* Maintain padding for buttons */
cursor: pointer; /* Make the list items look clickable */
transition: background-color 0.3s ease, color 0.3s ease; /* Smooth transition for background and color */
}
/* Style for the last item in the row */
.taskpriority-view li:last-child {
margin-right: 0;
}
/* Style for selected items */
.taskpriority-view li.selected,
.taskpriority-view:not(:has(.selected)) li:first-child {
font-weight: 900;
border-radius: 10px;
background-color: #1A3665; /* Dark blue color for selected button */
color: white;
}
/* Media query for tablets and smaller screens */
@media (max-width: 768px) {
.taskpriority-view li {
width: calc(50% - 20px); /* Adjust width for 2 buttons per row on smaller screens */
}
}
/* Media query for phones */
@media (max-width: 480px) {
.taskpriority-view li {
width: calc(100% - 20px); /* Full width button on phones */
margin-right: 0;
}
}
Can you guys help me with how I can get the output?
Thank you in advance.
Regards,
Dilip