1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- @use 'sass:math';
- // 24px input widget size.
- $size: 1.5rem;
- $marker-size: 1rem;
- $px: 0.0625rem;
- $marker-offset: math.div($size - $marker-size, 2) - $px;
- $radio-checkbox-label-gap: theme('spacing.[2.5]');
- // Both input types are very similar in appearance and layout.
- @mixin radio-checkbox-base() {
- @include input-base();
- display: inline-block;
- position: relative;
- height: $size;
- width: $size;
- cursor: pointer;
- margin-inline-end: $radio-checkbox-label-gap;
- // Prevent the checkbox or radio button from shrinking when the label is long.
- flex-shrink: 0;
- &::before {
- content: '';
- position: absolute;
- top: $marker-offset;
- inset-inline-start: $marker-offset;
- width: $marker-size;
- height: $marker-size;
- }
- &:checked::before {
- background: theme('colors.border-button-outline-default');
- @media (forced-colors: active) {
- background: Highlight;
- }
- }
- }
- input[type='radio'] {
- @include radio-checkbox-base();
- display: inline-block;
- border-radius: theme('borderRadius.full');
- &:checked::before {
- mask-image: url('#{$images-root}icons/radio-full.svg');
- }
- }
- input[type='checkbox'] {
- @include radio-checkbox-base();
- border-radius: theme('borderRadius.sm');
- // Legacy alignment for checkboxes, particularly within listings.
- vertical-align: bottom;
- &:checked::before {
- mask-image: url('#{$images-root}icons/check.svg');
- }
- }
|