index.less 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. @import '../../style/themes/index';
  2. @import '../../style/mixins/index';
  3. @import './status';
  4. @menu-prefix-cls: ~'@{ant-prefix}-menu';
  5. @menu-animation-duration-normal: 0.15s;
  6. .accessibility-focus() {
  7. box-shadow: 0 0 0 2px @primary-2;
  8. }
  9. // TODO: Should remove icon style compatible in v5
  10. // default theme
  11. .@{menu-prefix-cls} {
  12. .reset-component();
  13. margin-bottom: 0;
  14. padding-left: 0; // Override default ul/ol
  15. color: @menu-item-color;
  16. font-size: @menu-item-font-size;
  17. line-height: 0; // Fix display inline-block gap
  18. text-align: left;
  19. list-style: none;
  20. background: @menu-bg;
  21. outline: none;
  22. box-shadow: @box-shadow-base;
  23. transition: background @animation-duration-slow,
  24. width @animation-duration-slow cubic-bezier(0.2, 0, 0, 1) 0s;
  25. .clearfix();
  26. &&-root:focus-visible {
  27. .accessibility-focus();
  28. }
  29. ul,
  30. ol {
  31. margin: 0;
  32. padding: 0;
  33. list-style: none;
  34. }
  35. // Overflow ellipsis
  36. &-overflow {
  37. display: flex;
  38. &-item {
  39. flex: none;
  40. }
  41. }
  42. &-hidden,
  43. &-submenu-hidden {
  44. display: none;
  45. }
  46. &-item-group-title {
  47. height: @menu-item-group-height;
  48. padding: 8px 16px;
  49. color: @menu-item-group-title-color;
  50. font-size: @menu-item-group-title-font-size;
  51. line-height: @menu-item-group-height;
  52. transition: all @animation-duration-slow;
  53. }
  54. &-horizontal &-submenu {
  55. transition: border-color @animation-duration-slow @ease-in-out,
  56. background @animation-duration-slow @ease-in-out;
  57. }
  58. &-submenu,
  59. &-submenu-inline {
  60. transition: border-color @animation-duration-slow @ease-in-out,
  61. background @animation-duration-slow @ease-in-out,
  62. padding @menu-animation-duration-normal @ease-in-out;
  63. }
  64. &-submenu-selected {
  65. color: @menu-highlight-color;
  66. }
  67. &-item:active,
  68. &-submenu-title:active {
  69. background: @menu-item-active-bg;
  70. }
  71. &-submenu &-sub {
  72. cursor: initial;
  73. transition: background @animation-duration-slow @ease-in-out,
  74. padding @animation-duration-slow @ease-in-out;
  75. }
  76. &-title-content {
  77. transition: color @animation-duration-slow;
  78. }
  79. &-item a {
  80. color: @menu-item-color;
  81. &:hover {
  82. color: @menu-highlight-color;
  83. }
  84. &::before {
  85. position: absolute;
  86. top: 0;
  87. right: 0;
  88. bottom: 0;
  89. left: 0;
  90. background-color: transparent;
  91. content: '';
  92. }
  93. }
  94. // https://github.com/ant-design/ant-design/issues/19809
  95. &-item > .@{ant-prefix}-badge a {
  96. color: @menu-item-color;
  97. &:hover {
  98. color: @menu-highlight-color;
  99. }
  100. }
  101. &-item-divider {
  102. overflow: hidden;
  103. line-height: 0;
  104. border-color: @border-color-split;
  105. border-style: solid;
  106. border-width: 1px 0 0;
  107. }
  108. &-item-divider-dashed {
  109. border-style: dashed;
  110. }
  111. &-horizontal &-item,
  112. &-horizontal &-submenu {
  113. margin-top: -1px;
  114. }
  115. &-horizontal > &-item:hover,
  116. &-horizontal > &-item-active,
  117. &-horizontal > &-submenu &-submenu-title:hover {
  118. background-color: transparent;
  119. }
  120. &-item-selected {
  121. color: @menu-highlight-color;
  122. a,
  123. a:hover {
  124. color: @menu-highlight-color;
  125. }
  126. }
  127. &:not(&-horizontal) &-item-selected {
  128. background-color: @menu-item-active-bg;
  129. }
  130. &-inline,
  131. &-vertical,
  132. &-vertical-left {
  133. border-right: @border-width-base @border-style-base @border-color-split;
  134. }
  135. &-vertical-right {
  136. border-left: @border-width-base @border-style-base @border-color-split;
  137. }
  138. &-vertical&-sub,
  139. &-vertical-left&-sub,
  140. &-vertical-right&-sub {
  141. min-width: 160px;
  142. max-height: calc(100vh - 100px);
  143. padding: 0;
  144. overflow: hidden;
  145. border-right: 0;
  146. // https://github.com/ant-design/ant-design/issues/22244
  147. // https://github.com/ant-design/ant-design/issues/26812
  148. &:not([class*='-active']) {
  149. overflow-x: hidden;
  150. overflow-y: auto;
  151. }
  152. .@{menu-prefix-cls}-item {
  153. left: 0;
  154. margin-left: 0;
  155. border-right: 0;
  156. &::after {
  157. border-right: 0;
  158. }
  159. }
  160. > .@{menu-prefix-cls}-item,
  161. > .@{menu-prefix-cls}-submenu {
  162. transform-origin: 0 0;
  163. }
  164. }
  165. &-horizontal&-sub {
  166. min-width: 114px; // in case of submenu width is too big: https://codesandbox.io/s/qvpwm6mk66
  167. }
  168. &-horizontal &-item,
  169. &-horizontal &-submenu-title {
  170. transition: border-color @animation-duration-slow, background @animation-duration-slow;
  171. }
  172. &-item,
  173. &-submenu-title {
  174. position: relative;
  175. display: block;
  176. margin: 0;
  177. padding: @menu-item-padding;
  178. white-space: nowrap;
  179. cursor: pointer;
  180. transition: border-color @animation-duration-slow, background @animation-duration-slow,
  181. padding @animation-duration-slow @ease-in-out;
  182. .@{menu-prefix-cls}-item-icon,
  183. .@{iconfont-css-prefix} {
  184. min-width: 14px;
  185. font-size: @menu-icon-size;
  186. transition: font-size @menu-animation-duration-normal @ease-out,
  187. margin @animation-duration-slow @ease-in-out, color @animation-duration-slow;
  188. + span {
  189. margin-left: @menu-icon-margin-right;
  190. opacity: 1;
  191. transition: opacity @animation-duration-slow @ease-in-out, margin @animation-duration-slow,
  192. color @animation-duration-slow;
  193. }
  194. }
  195. .@{menu-prefix-cls}-item-icon.svg {
  196. vertical-align: -0.125em;
  197. }
  198. &.@{menu-prefix-cls}-item-only-child {
  199. > .@{iconfont-css-prefix},
  200. > .@{menu-prefix-cls}-item-icon {
  201. margin-right: 0;
  202. }
  203. }
  204. &:not(.@{menu-prefix-cls}-item-disabled):focus-visible {
  205. .accessibility-focus();
  206. }
  207. }
  208. & > &-item-divider {
  209. margin: 1px 0;
  210. padding: 0;
  211. }
  212. &-submenu {
  213. &-popup {
  214. position: absolute;
  215. z-index: @zindex-dropdown;
  216. background: transparent;
  217. border-radius: @border-radius-base;
  218. box-shadow: none;
  219. transform-origin: 0 0;
  220. // https://github.com/ant-design/ant-design/issues/13955
  221. &::before {
  222. position: absolute;
  223. top: -7px;
  224. right: 0;
  225. bottom: 0;
  226. left: 0;
  227. z-index: -1;
  228. width: 100%;
  229. height: 100%;
  230. opacity: 0.0001;
  231. content: ' ';
  232. }
  233. }
  234. // https://github.com/ant-design/ant-design/issues/13955
  235. &-placement-rightTop::before {
  236. top: 0;
  237. left: -7px;
  238. }
  239. > .@{menu-prefix-cls} {
  240. background-color: @menu-bg;
  241. border-radius: @border-radius-base;
  242. &-submenu-title::after {
  243. transition: transform @animation-duration-slow @ease-in-out;
  244. }
  245. }
  246. &-popup > .@{menu-prefix-cls} {
  247. background-color: @menu-popup-bg;
  248. }
  249. &-expand-icon,
  250. &-arrow {
  251. position: absolute;
  252. top: 50%;
  253. right: 16px;
  254. width: 10px;
  255. color: @menu-item-color;
  256. transform: translateY(-50%);
  257. transition: transform @animation-duration-slow @ease-in-out;
  258. }
  259. &-arrow {
  260. // →
  261. &::before,
  262. &::after {
  263. position: absolute;
  264. width: 6px;
  265. height: 1.5px;
  266. background-color: currentcolor;
  267. border-radius: 2px;
  268. transition: background @animation-duration-slow @ease-in-out,
  269. transform @animation-duration-slow @ease-in-out, top @animation-duration-slow @ease-in-out,
  270. color @animation-duration-slow @ease-in-out;
  271. content: '';
  272. }
  273. &::before {
  274. transform: rotate(45deg) translateY(-2.5px);
  275. }
  276. &::after {
  277. transform: rotate(-45deg) translateY(2.5px);
  278. }
  279. }
  280. &:hover > &-title > &-expand-icon,
  281. &:hover > &-title > &-arrow {
  282. color: @menu-highlight-color;
  283. }
  284. .@{menu-prefix-cls}-inline-collapsed &-arrow,
  285. &-inline &-arrow {
  286. // ↓
  287. &::before {
  288. transform: rotate(-45deg) translateX(2.5px);
  289. }
  290. &::after {
  291. transform: rotate(45deg) translateX(-2.5px);
  292. }
  293. }
  294. &-horizontal &-arrow {
  295. display: none;
  296. }
  297. &-open&-inline > &-title > &-arrow {
  298. // ↑
  299. transform: translateY(-2px);
  300. &::after {
  301. transform: rotate(-45deg) translateX(-2.5px);
  302. }
  303. &::before {
  304. transform: rotate(45deg) translateX(2.5px);
  305. }
  306. }
  307. }
  308. &-vertical &-submenu-selected,
  309. &-vertical-left &-submenu-selected,
  310. &-vertical-right &-submenu-selected {
  311. color: @menu-highlight-color;
  312. }
  313. &-horizontal {
  314. line-height: @menu-horizontal-line-height;
  315. border: 0;
  316. border-bottom: @border-width-base @border-style-base @border-color-split;
  317. box-shadow: none;
  318. &:not(.@{menu-prefix-cls}-dark) {
  319. > .@{menu-prefix-cls}-item,
  320. > .@{menu-prefix-cls}-submenu {
  321. margin-top: -1px;
  322. margin-bottom: 0;
  323. padding: @menu-item-padding;
  324. &:hover,
  325. &-active,
  326. &-open,
  327. &-selected {
  328. color: @menu-highlight-color;
  329. &::after {
  330. border-bottom: 2px solid @menu-highlight-color;
  331. }
  332. }
  333. }
  334. }
  335. > .@{menu-prefix-cls}-item,
  336. > .@{menu-prefix-cls}-submenu {
  337. position: relative;
  338. top: 1px;
  339. display: inline-block;
  340. vertical-align: bottom;
  341. &::after {
  342. position: absolute;
  343. right: @menu-item-padding-horizontal;
  344. bottom: 0;
  345. left: @menu-item-padding-horizontal;
  346. border-bottom: 2px solid transparent;
  347. transition: border-color @animation-duration-slow @ease-in-out;
  348. content: '';
  349. }
  350. }
  351. > .@{menu-prefix-cls}-submenu > .@{menu-prefix-cls}-submenu-title {
  352. padding: 0;
  353. }
  354. > .@{menu-prefix-cls}-item {
  355. a {
  356. color: @menu-item-color;
  357. &:hover {
  358. color: @menu-highlight-color;
  359. }
  360. &::before {
  361. bottom: -2px;
  362. }
  363. }
  364. &-selected a {
  365. color: @menu-highlight-color;
  366. }
  367. }
  368. &::after {
  369. display: block;
  370. clear: both;
  371. height: 0;
  372. content: '\20';
  373. }
  374. }
  375. &-vertical,
  376. &-vertical-left,
  377. &-vertical-right,
  378. &-inline {
  379. .@{menu-prefix-cls}-item {
  380. position: relative;
  381. &::after {
  382. position: absolute;
  383. top: 0;
  384. right: 0;
  385. bottom: 0;
  386. border-right: @menu-item-active-border-width solid @menu-highlight-color;
  387. transform: scaleY(0.0001);
  388. opacity: 0;
  389. transition: transform @menu-animation-duration-normal @ease-out,
  390. opacity @menu-animation-duration-normal @ease-out;
  391. content: '';
  392. }
  393. }
  394. .@{menu-prefix-cls}-item,
  395. .@{menu-prefix-cls}-submenu-title {
  396. height: @menu-item-height;
  397. margin-top: @menu-item-vertical-margin;
  398. margin-bottom: @menu-item-vertical-margin;
  399. padding: 0 16px;
  400. overflow: hidden;
  401. line-height: @menu-item-height;
  402. text-overflow: ellipsis;
  403. }
  404. // disable margin collapsed
  405. .@{menu-prefix-cls}-submenu {
  406. padding-bottom: 0.02px;
  407. }
  408. .@{menu-prefix-cls}-item:not(:last-child) {
  409. margin-bottom: @menu-item-boundary-margin;
  410. }
  411. > .@{menu-prefix-cls}-item,
  412. > .@{menu-prefix-cls}-submenu > .@{menu-prefix-cls}-submenu-title {
  413. height: @menu-inline-toplevel-item-height;
  414. line-height: @menu-inline-toplevel-item-height;
  415. }
  416. }
  417. &-vertical {
  418. .@{menu-prefix-cls}-item-group-list .@{menu-prefix-cls}-submenu-title,
  419. .@{menu-prefix-cls}-submenu-title {
  420. padding-right: 34px;
  421. }
  422. }
  423. &-inline {
  424. width: 100%;
  425. .@{menu-prefix-cls}-selected,
  426. .@{menu-prefix-cls}-item-selected {
  427. &::after {
  428. transform: scaleY(1);
  429. opacity: 1;
  430. transition: transform @menu-animation-duration-normal @ease-in-out,
  431. opacity @menu-animation-duration-normal @ease-in-out;
  432. }
  433. }
  434. .@{menu-prefix-cls}-item,
  435. .@{menu-prefix-cls}-submenu-title {
  436. width: ~'calc(100% + 1px)';
  437. }
  438. .@{menu-prefix-cls}-item-group-list .@{menu-prefix-cls}-submenu-title,
  439. .@{menu-prefix-cls}-submenu-title {
  440. padding-right: 34px;
  441. }
  442. // Motion enhance for first level
  443. &.@{menu-prefix-cls}-root {
  444. .@{menu-prefix-cls}-item,
  445. .@{menu-prefix-cls}-submenu-title {
  446. display: flex;
  447. align-items: center;
  448. transition: border-color @animation-duration-slow, background @animation-duration-slow,
  449. padding 0.1s @ease-out;
  450. > .@{menu-prefix-cls}-title-content {
  451. flex: auto;
  452. min-width: 0;
  453. overflow: hidden;
  454. text-overflow: ellipsis;
  455. }
  456. > * {
  457. flex: none;
  458. }
  459. }
  460. }
  461. }
  462. &&-inline-collapsed {
  463. width: @menu-collapsed-width;
  464. > .@{menu-prefix-cls}-item,
  465. > .@{menu-prefix-cls}-item-group
  466. > .@{menu-prefix-cls}-item-group-list
  467. > .@{menu-prefix-cls}-item,
  468. > .@{menu-prefix-cls}-item-group
  469. > .@{menu-prefix-cls}-item-group-list
  470. > .@{menu-prefix-cls}-submenu
  471. > .@{menu-prefix-cls}-submenu-title,
  472. > .@{menu-prefix-cls}-submenu > .@{menu-prefix-cls}-submenu-title {
  473. left: 0;
  474. padding: 0 ~'calc(50% - @{menu-icon-size-lg} / 2)';
  475. text-overflow: clip;
  476. .@{menu-prefix-cls}-submenu-arrow {
  477. opacity: 0;
  478. }
  479. .@{menu-prefix-cls}-item-icon,
  480. .@{iconfont-css-prefix} {
  481. margin: 0;
  482. font-size: @menu-icon-size-lg;
  483. line-height: @menu-item-height;
  484. + span {
  485. display: inline-block;
  486. opacity: 0;
  487. }
  488. }
  489. }
  490. .@{menu-prefix-cls}-item-icon,
  491. .@{iconfont-css-prefix} {
  492. display: inline-block;
  493. }
  494. &-tooltip {
  495. pointer-events: none;
  496. .@{menu-prefix-cls}-item-icon,
  497. .@{iconfont-css-prefix} {
  498. display: none;
  499. }
  500. a {
  501. color: @text-color-dark;
  502. }
  503. }
  504. .@{menu-prefix-cls}-item-group-title {
  505. padding-right: 4px;
  506. padding-left: 4px;
  507. overflow: hidden;
  508. white-space: nowrap;
  509. text-overflow: ellipsis;
  510. }
  511. }
  512. &-item-group-list {
  513. margin: 0;
  514. padding: 0;
  515. .@{menu-prefix-cls}-item,
  516. .@{menu-prefix-cls}-submenu-title {
  517. padding: 0 16px 0 28px;
  518. }
  519. }
  520. &-root&-vertical,
  521. &-root&-vertical-left,
  522. &-root&-vertical-right,
  523. &-root&-inline {
  524. box-shadow: none;
  525. }
  526. &-root&-inline-collapsed {
  527. .@{menu-prefix-cls}-item,
  528. .@{menu-prefix-cls}-submenu .@{menu-prefix-cls}-submenu-title {
  529. > .@{menu-prefix-cls}-inline-collapsed-noicon {
  530. font-size: @menu-icon-size-lg;
  531. text-align: center;
  532. }
  533. }
  534. }
  535. &-sub&-inline {
  536. padding: 0;
  537. background: @menu-inline-submenu-bg;
  538. border: 0;
  539. border-radius: 0;
  540. box-shadow: none;
  541. & > .@{menu-prefix-cls}-item,
  542. & > .@{menu-prefix-cls}-submenu > .@{menu-prefix-cls}-submenu-title {
  543. height: @menu-item-height;
  544. line-height: @menu-item-height;
  545. list-style-position: inside;
  546. list-style-type: disc;
  547. }
  548. & .@{menu-prefix-cls}-item-group-title {
  549. padding-left: 32px;
  550. }
  551. }
  552. // Disabled state sets text to gray and nukes hover/tab effects
  553. &-item-disabled,
  554. &-submenu-disabled {
  555. color: @disabled-color !important;
  556. background: none;
  557. cursor: not-allowed;
  558. &::after {
  559. border-color: transparent !important;
  560. }
  561. a {
  562. color: @disabled-color !important;
  563. pointer-events: none;
  564. }
  565. > .@{menu-prefix-cls}-submenu-title {
  566. color: @disabled-color !important;
  567. cursor: not-allowed;
  568. > .@{menu-prefix-cls}-submenu-arrow {
  569. &::before,
  570. &::after {
  571. background: @disabled-color !important;
  572. }
  573. }
  574. }
  575. }
  576. }
  577. // Integration with header element so menu items have the same height
  578. .@{ant-prefix}-layout-header {
  579. .@{menu-prefix-cls} {
  580. line-height: inherit;
  581. }
  582. }
  583. // https://github.com/ant-design/ant-design/issues/32950
  584. .@{ant-prefix}-menu-inline-collapsed-tooltip {
  585. a,
  586. a:hover {
  587. color: @white;
  588. }
  589. }
  590. @import './light';
  591. @import './dark';
  592. @import './rtl';