2
0

_radio-checkbox.scss 1.4 KB

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