_radio-checkbox.scss 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. @use 'sass:math';
  2. $size: 30;
  3. $marker-size: 18;
  4. $marker-offset: math.div($size - $marker-size, 2) - 1;
  5. $radio-checkbox-label-gap: theme('spacing.[2.5]');
  6. $radio-checkbox-line-gap: theme('spacing.[2.5]');
  7. // Both input types are very similar in appearance and layout.
  8. @mixin radio-checkbox-base() {
  9. @include input-base();
  10. display: inline-block;
  11. position: relative;
  12. height: rem($size);
  13. width: rem($size);
  14. cursor: pointer;
  15. margin-inline-end: $radio-checkbox-label-gap;
  16. &::before {
  17. content: '';
  18. position: absolute;
  19. top: rem($marker-offset);
  20. inset-inline-start: rem($marker-offset);
  21. width: rem($marker-size);
  22. height: rem($marker-size);
  23. }
  24. &:checked::before {
  25. background: $color-teal;
  26. @media (forced-colors: active) {
  27. background: Highlight;
  28. }
  29. }
  30. }
  31. input[type='radio'] {
  32. @include radio-checkbox-base();
  33. display: inline-block;
  34. border-radius: theme('borderRadius.full');
  35. &:checked::before {
  36. mask-image: url('#{$images-root}icons/radio-full.svg');
  37. }
  38. }
  39. input[type='checkbox'] {
  40. @include radio-checkbox-base();
  41. border-radius: theme('borderRadius.sm');
  42. // Legacy alignment for checkboxes, particularly within listings.
  43. vertical-align: bottom;
  44. &::before {
  45. // Checkboxes look better with a slightly larger offset.
  46. top: rem($marker-offset + 1);
  47. inset-inline-start: rem($marker-offset + 1);
  48. }
  49. &:checked::before {
  50. mask-image: url('#{$images-root}icons/tick.svg');
  51. }
  52. }