_select.scss 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. @use 'sass:map';
  2. @use 'sass:math';
  3. @use '../../settings' as *;
  4. @use './input-base' as *;
  5. $select-size: $text-input-height;
  6. $chevron-size: 0.375rem;
  7. $chevron-offset: math.div($select-size - $chevron-size, 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-y: $chevron-offset, $chevron-offset;
  24. background-position-x: calc(100% - $chevron-offset - $chevron-size),
  25. calc(100% - $chevron-offset);
  26. [dir='rtl'] & {
  27. background-position-x: $chevron-offset,
  28. calc($chevron-offset + $chevron-size);
  29. }
  30. background-size:
  31. $chevron-size $chevron-size,
  32. $chevron-size $chevron-size;
  33. background-repeat: no-repeat;
  34. }
  35. select {
  36. @include select-arrow();
  37. @apply w-body-text-large;
  38. // Firefox workaround – Set a large line height (but smaller than min height) so the field’s text has enough top padding.
  39. line-height: 2.2;
  40. min-height: $select-size;
  41. padding: 0 theme('spacing.5');
  42. padding-inline-end: $select-size;
  43. // Prevent the element from overflowing the container.
  44. max-width: 100%;
  45. @include input-base();
  46. @media (forced-colors: active) {
  47. appearance: auto;
  48. }
  49. }
  50. select[multiple] {
  51. background-image: none;
  52. min-height: theme('spacing.40');
  53. padding: 0;
  54. option {
  55. padding: 0 theme('spacing.5');
  56. }
  57. }