_radio-buttons.scss 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* Radio Buttons
  2. ========================================================================== */
  3. // Remove default Radio Buttons
  4. [type="radio"]:not(:checked),
  5. [type="radio"]:checked {
  6. position: absolute;
  7. opacity: 0;
  8. pointer-events: none;
  9. }
  10. [type="radio"]:not(:checked) + span,
  11. [type="radio"]:checked + span {
  12. position: relative;
  13. padding-left: 35px;
  14. cursor: pointer;
  15. display: inline-block;
  16. height: 25px;
  17. line-height: 25px;
  18. font-size: 1rem;
  19. transition: .28s ease;
  20. user-select: none;
  21. }
  22. [type="radio"] + span:before,
  23. [type="radio"] + span:after {
  24. content: '';
  25. position: absolute;
  26. left: 0;
  27. top: 0;
  28. margin: 4px;
  29. width: 16px;
  30. height: 16px;
  31. z-index: 0;
  32. transition: .28s ease;
  33. }
  34. /* Unchecked styles */
  35. [type="radio"]:not(:checked) + span:before,
  36. [type="radio"]:not(:checked) + span:after,
  37. [type="radio"]:checked + span:before,
  38. [type="radio"]:checked + span:after,
  39. [type="radio"].with-gap:checked + span:before,
  40. [type="radio"].with-gap:checked + span:after {
  41. border-radius: 50%;
  42. }
  43. [type="radio"]:not(:checked) + span:before,
  44. [type="radio"]:not(:checked) + span:after {
  45. border: 2px solid $radio-empty-color;
  46. }
  47. [type="radio"]:not(:checked) + span:after {
  48. transform: scale(0);
  49. }
  50. /* Checked styles */
  51. [type="radio"]:checked + span:before {
  52. border: 2px solid transparent;
  53. }
  54. [type="radio"]:checked + span:after,
  55. [type="radio"].with-gap:checked + span:before,
  56. [type="radio"].with-gap:checked + span:after {
  57. border: $radio-border;
  58. }
  59. [type="radio"]:checked + span:after,
  60. [type="radio"].with-gap:checked + span:after {
  61. background-color: $radio-fill-color;
  62. }
  63. [type="radio"]:checked + span:after {
  64. transform: scale(1.02);
  65. }
  66. /* Radio With gap */
  67. [type="radio"].with-gap:checked + span:after {
  68. transform: scale(.5);
  69. }
  70. /* Focused styles */
  71. [type="radio"].tabbed:focus + span:before {
  72. box-shadow: 0 0 0 10px rgba(0,0,0,.1);
  73. }
  74. /* Disabled Radio With gap */
  75. [type="radio"].with-gap:disabled:checked + span:before {
  76. border: 2px solid $input-disabled-color;
  77. }
  78. [type="radio"].with-gap:disabled:checked + span:after {
  79. border: none;
  80. background-color: $input-disabled-color;
  81. }
  82. /* Disabled style */
  83. [type="radio"]:disabled:not(:checked) + span:before,
  84. [type="radio"]:disabled:checked + span:before {
  85. background-color: transparent;
  86. border-color: $input-disabled-color;
  87. }
  88. [type="radio"]:disabled + span {
  89. color: $input-disabled-color;
  90. }
  91. [type="radio"]:disabled:not(:checked) + span:before {
  92. border-color: $input-disabled-color;
  93. }
  94. [type="radio"]:disabled:checked + span:after {
  95. background-color: $input-disabled-color;
  96. border-color: $input-disabled-solid-color;
  97. }