_select.scss 1.5 KB

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