index.less 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. @import '../../style/themes/index';
  2. @import '../../style/mixins/index';
  3. @import './mixin';
  4. @btn-prefix-cls: ~'@{ant-prefix}-btn';
  5. // for compatible
  6. @btn-ghost-color: @text-color;
  7. @btn-ghost-bg: transparent;
  8. @btn-ghost-border: @border-color-base;
  9. // Button styles
  10. // -----------------------------
  11. .@{btn-prefix-cls} {
  12. // Fixing https://github.com/ant-design/ant-design/issues/12978
  13. // Fixing https://github.com/ant-design/ant-design/issues/20058
  14. // Fixing https://github.com/ant-design/ant-design/issues/19972
  15. // Fixing https://github.com/ant-design/ant-design/issues/18107
  16. // Fixing https://github.com/ant-design/ant-design/issues/13214
  17. // It is a render problem of chrome, which is only happened in the codesandbox demo
  18. // 0.001px solution works and I don't know why
  19. line-height: @btn-line-height;
  20. .btn();
  21. .btn-default();
  22. // Fix loading button animation
  23. // https://github.com/ant-design/ant-design/issues/24323
  24. > span {
  25. display: inline-block;
  26. }
  27. &-primary {
  28. .btn-primary();
  29. .@{btn-prefix-cls}-group &:not(:first-child):not(:last-child) {
  30. border-right-color: @btn-group-border;
  31. border-left-color: @btn-group-border;
  32. &:disabled {
  33. border-color: @btn-default-border;
  34. }
  35. }
  36. .@{btn-prefix-cls}-group &:first-child {
  37. &:not(:last-child) {
  38. border-right-color: @btn-group-border;
  39. &[disabled] {
  40. border-right-color: @btn-default-border;
  41. }
  42. }
  43. }
  44. .@{btn-prefix-cls}-group &:last-child:not(:first-child),
  45. .@{btn-prefix-cls}-group & + & {
  46. border-left-color: @btn-group-border;
  47. &[disabled] {
  48. border-left-color: @btn-default-border;
  49. }
  50. }
  51. }
  52. &-ghost {
  53. .btn-ghost();
  54. }
  55. &-dashed {
  56. .btn-dashed();
  57. }
  58. // type="danger" will deprecated
  59. // use danger instead
  60. &-danger {
  61. .btn-danger();
  62. }
  63. &-link {
  64. .btn-link();
  65. }
  66. &-text {
  67. .btn-text();
  68. }
  69. &-dangerous {
  70. .btn-danger-default();
  71. }
  72. &-dangerous&-primary {
  73. .btn-danger();
  74. }
  75. &-dangerous&-link {
  76. .btn-danger-link();
  77. }
  78. &-dangerous&-text {
  79. .btn-danger-text();
  80. }
  81. &-icon-only {
  82. .btn-square(@btn-prefix-cls);
  83. vertical-align: -3px;
  84. > .@{iconfont-css-prefix} {
  85. display: flex;
  86. justify-content: center;
  87. }
  88. .@{iconfont-css-prefix}-loading {
  89. padding: 0 !important;
  90. }
  91. }
  92. // https://github.com/ant-design/ant-design/issues/32365
  93. a&-icon-only {
  94. vertical-align: -1px;
  95. > .@{iconfont-css-prefix} {
  96. display: inline;
  97. }
  98. }
  99. &-round {
  100. .btn-round(@btn-prefix-cls);
  101. &.@{btn-prefix-cls}-icon-only {
  102. width: auto;
  103. }
  104. }
  105. &-circle {
  106. .btn-circle(@btn-prefix-cls);
  107. }
  108. &::before {
  109. position: absolute;
  110. top: -@btn-border-width;
  111. right: -@btn-border-width;
  112. bottom: -@btn-border-width;
  113. left: -@btn-border-width;
  114. z-index: 1;
  115. display: none;
  116. background: @component-background;
  117. border-radius: inherit;
  118. opacity: 0.35;
  119. transition: opacity 0.2s;
  120. content: '';
  121. pointer-events: none;
  122. }
  123. .@{iconfont-css-prefix} {
  124. transition: margin-left 0.3s @ease-in-out;
  125. // Follow icon blur under windows. Change the render.
  126. // https://github.com/ant-design/ant-design/issues/13924
  127. &.@{iconfont-css-prefix}-plus,
  128. &.@{iconfont-css-prefix}-minus {
  129. > svg {
  130. shape-rendering: optimizespeed;
  131. }
  132. }
  133. }
  134. &&-loading {
  135. position: relative;
  136. cursor: default;
  137. &::before {
  138. display: block;
  139. }
  140. }
  141. & > &-loading-icon {
  142. transition: width 0.3s @ease-in-out, opacity 0.3s @ease-in-out;
  143. .@{iconfont-css-prefix} {
  144. padding-right: @padding-xs;
  145. animation: none;
  146. // for smooth button padding transition
  147. svg {
  148. animation: loadingCircle 1s infinite linear;
  149. }
  150. }
  151. }
  152. &-group {
  153. .btn-group(@btn-prefix-cls);
  154. }
  155. // http://stackoverflow.com/a/21281554/3040605
  156. &:focus > span,
  157. &:active > span {
  158. position: relative;
  159. }
  160. // To ensure that a space will be placed between character and `Icon`.
  161. > .@{iconfont-css-prefix} + span,
  162. > span + .@{iconfont-css-prefix} {
  163. margin-left: @margin-xs;
  164. }
  165. &&-background-ghost {
  166. color: @btn-default-ghost-color;
  167. border-color: @btn-default-ghost-border;
  168. &,
  169. &:hover,
  170. &:active,
  171. &:focus {
  172. background: @btn-default-ghost-bg;
  173. }
  174. &:hover,
  175. &:focus {
  176. color: @primary-color-hover;
  177. border-color: @primary-color-hover;
  178. }
  179. &:active {
  180. color: @primary-color-active;
  181. border-color: @primary-color-active;
  182. }
  183. &[disabled] {
  184. color: @disabled-color;
  185. background: @btn-default-ghost-bg;
  186. border-color: @btn-default-border;
  187. }
  188. }
  189. &-background-ghost&-primary {
  190. .button-variant-ghost(@btn-primary-bg, @btn-primary-bg, @primary-color-hover, @primary-color-active);
  191. }
  192. &-background-ghost&-danger {
  193. .button-variant-ghost(@btn-danger-border, @btn-danger-border, @error-color-hover, @error-color-active);
  194. }
  195. &-background-ghost&-dangerous {
  196. .button-variant-ghost(@btn-danger-border, @btn-danger-border, @error-color-hover, @error-color-active);
  197. }
  198. &-background-ghost&-dangerous&-link {
  199. .button-variant-ghost(@btn-danger-border, transparent, @error-color-hover, @error-color-active);
  200. }
  201. &-two-chinese-chars::first-letter {
  202. letter-spacing: 0.34em;
  203. }
  204. &-two-chinese-chars > *:not(.@{iconfont-css-prefix}) {
  205. margin-right: -0.34em;
  206. letter-spacing: 0.34em;
  207. }
  208. &&-block {
  209. width: 100%;
  210. }
  211. // https://github.com/ant-design/ant-design/issues/12681
  212. // same method as Select
  213. &:empty {
  214. display: inline-block;
  215. width: 0;
  216. visibility: hidden;
  217. content: '\a0';
  218. }
  219. }
  220. a.@{btn-prefix-cls} {
  221. // Fixing https://github.com/ant-design/ant-design/issues/12978
  222. // https://github.com/ant-design/ant-design/issues/29978
  223. // It is a render problem of chrome, which is only happened in the codesandbox demo
  224. // 0.1px for padding-top solution works and I don't why
  225. padding-top: 0.01px !important;
  226. line-height: @btn-height-base - 2px;
  227. &-disabled {
  228. .btn-href-disabled();
  229. }
  230. &-lg {
  231. line-height: @btn-height-lg - 2px;
  232. }
  233. &-sm {
  234. line-height: @btn-height-sm - 2px;
  235. }
  236. }
  237. @import './space-compact';
  238. @import './rtl';