checkbox.css 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /* mixins & extensions */
  2. @keyframes in {
  3. 0% {
  4. opacity: 0;
  5. }
  6. 100% {
  7. opacity: 1;
  8. }
  9. }
  10. @keyframes in-down {
  11. 0% {
  12. opacity: 0;
  13. transform: translate3D(0, -5px, 0);
  14. }
  15. 100% {
  16. opacity: 1;
  17. transform: translate3D(0, 0, 0);
  18. }
  19. }
  20. @keyframes in-up {
  21. 0% {
  22. opacity: 0;
  23. transform: translate3D(0, 5px, 0);
  24. }
  25. 100% {
  26. opacity: 1;
  27. transform: translate3D(0, 0, 0);
  28. }
  29. }
  30. @keyframes in-scale {
  31. 0% {
  32. opacity: 0;
  33. transform: scale3D(0.95, 0.95, 1);
  34. }
  35. 100% {
  36. opacity: 1;
  37. transform: scale3D(1, 1, 1);
  38. }
  39. }
  40. :root {
  41. --calcite-animation-timing: calc(150ms * var(--calcite-internal-duration-factor));
  42. --calcite-internal-duration-factor: var(--calcite-duration-factor, 1);
  43. --calcite-internal-animation-timing-fast: calc(100ms * var(--calcite-internal-duration-factor));
  44. --calcite-internal-animation-timing-medium: calc(200ms * var(--calcite-internal-duration-factor));
  45. --calcite-internal-animation-timing-slow: calc(300ms * var(--calcite-internal-duration-factor));
  46. }
  47. .calcite-animate {
  48. opacity: 0;
  49. animation-fill-mode: both;
  50. animation-duration: var(--calcite-animation-timing);
  51. }
  52. .calcite-animate__in {
  53. animation-name: in;
  54. }
  55. .calcite-animate__in-down {
  56. animation-name: in-down;
  57. }
  58. .calcite-animate__in-up {
  59. animation-name: in-up;
  60. }
  61. .calcite-animate__in-scale {
  62. animation-name: in-scale;
  63. }
  64. /**
  65. * Currently only used in Checkbox.
  66. */
  67. :root {
  68. --calcite-popper-transition: var(--calcite-animation-timing);
  69. }
  70. :host([hidden]) {
  71. display: none;
  72. }
  73. /**
  74. * CSS Custom Properties
  75. *
  76. * These properties can be overridden using the component's tag as selector.
  77. *
  78. * @prop --calcite-checkbox-size: the width and height of the checkbox
  79. */
  80. :host([scale=s]) {
  81. --calcite-checkbox-size: 0.75rem;
  82. }
  83. :host([scale=m]) {
  84. --calcite-checkbox-size: var(--calcite-font-size--1);
  85. }
  86. :host([scale=l]) {
  87. --calcite-checkbox-size: 1rem;
  88. }
  89. :host {
  90. position: relative;
  91. display: inline-flex;
  92. cursor: pointer;
  93. -webkit-user-select: none;
  94. user-select: none;
  95. -webkit-tap-highlight-color: transparent;
  96. }
  97. :host .check-svg {
  98. pointer-events: none;
  99. box-sizing: border-box;
  100. display: block;
  101. overflow: hidden;
  102. background-color: var(--calcite-ui-foreground-1);
  103. fill: currentColor;
  104. stroke: currentColor;
  105. stroke-width: 1;
  106. transition-property: all;
  107. transition-duration: 150ms;
  108. transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  109. width: var(--calcite-checkbox-size);
  110. height: var(--calcite-checkbox-size);
  111. box-shadow: inset 0 0 0 1px var(--calcite-ui-border-input);
  112. color: var(--calcite-ui-background);
  113. }
  114. :host([checked]) .check-svg, :host([indeterminate]) .check-svg {
  115. background-color: var(--calcite-ui-brand);
  116. box-shadow: inset 0 0 0 1px var(--calcite-ui-brand);
  117. }
  118. :host([hovered]) .toggle .check-svg,
  119. :host .toggle:hover .check-svg {
  120. box-shadow: inset 0 0 0 2px var(--calcite-ui-brand);
  121. }
  122. :host .toggle:focus .check-svg,
  123. :host .toggle:active .check-svg {
  124. box-shadow: inset 0 0 0 1px var(--calcite-ui-brand), 0 0 0 2px var(--calcite-ui-foreground-1), 0 0 0 4px var(--calcite-ui-brand);
  125. transition: var(--calcite-animation-timing);
  126. }
  127. .toggle:focus-visible {
  128. outline: none;
  129. }
  130. :host([disabled]) {
  131. pointer-events: none;
  132. cursor: default;
  133. -webkit-user-select: none;
  134. user-select: none;
  135. opacity: var(--calcite-ui-opacity-disabled);
  136. }
  137. :host([disabled]) ::slotted([calcite-hydrated][disabled]),
  138. :host([disabled]) [calcite-hydrated][disabled] {
  139. /* prevent opacity stacking */
  140. opacity: 1;
  141. }
  142. ::slotted(input[slot=hidden-form-input]) {
  143. bottom: 0 !important;
  144. left: 0 !important;
  145. margin: 0 !important;
  146. opacity: 0 !important;
  147. outline: none !important;
  148. padding: 0 !important;
  149. position: absolute !important;
  150. right: 0 !important;
  151. top: 0 !important;
  152. transform: none !important;
  153. -webkit-appearance: none !important;
  154. z-index: -1 !important;
  155. }