_select.scss 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. @use 'sass:map';
  2. @use 'sass:math';
  3. $select-size: $text-input-height;
  4. $chevron-width: 0.375rem;
  5. $chevron-height: 0.375rem;
  6. $chevron-top-offset: math.div($select-size - $chevron-height, 2);
  7. $chevron-inline-end-offset: math.div($select-size - $chevron-width, 2);
  8. @mixin select-arrow() {
  9. background-image: linear-gradient(
  10. 45deg,
  11. transparent 50%,
  12. theme('colors.text-label') 33%,
  13. theme('colors.text-label') 66%,
  14. transparent 66%
  15. ),
  16. linear-gradient(
  17. -45deg,
  18. transparent 50%,
  19. theme('colors.text-label') 33%,
  20. theme('colors.text-label') 66%,
  21. transparent 66%
  22. );
  23. background-position:
  24. calc(100% - $chevron-top-offset - $chevron-width) $chevron-top-offset,
  25. calc(100% - $chevron-inline-end-offset) $chevron-top-offset;
  26. background-size:
  27. $chevron-width $chevron-width,
  28. $chevron-width $chevron-width;
  29. background-repeat: no-repeat;
  30. }
  31. select {
  32. @include input-base();
  33. @include select-arrow();
  34. @apply w-body-text-large;
  35. // Firefox workaround – Set a large line height (but smaller than min height) so the field’s text has enough top padding.
  36. line-height: 2.2;
  37. min-height: $select-size;
  38. padding: 0 theme('spacing.5');
  39. padding-inline-end: $select-size;
  40. // Prevent the element from overflowing the container.
  41. max-width: 100%;
  42. @media (forced-colors: active) {
  43. appearance: auto;
  44. }
  45. }
  46. select[multiple] {
  47. background-image: none;
  48. min-height: theme('spacing.40');
  49. padding: 0;
  50. option {
  51. padding: 0 theme('spacing.5');
  52. }
  53. }