_list-group.less 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. // Base class
  2. //
  3. // Easily usable on <ul>, <ol>, or <div>.
  4. .list-group {
  5. display: flex;
  6. flex-direction: column;
  7. // No need to set list-style: none; since .list-group-item is block level
  8. padding-left: 0; // reset padding because ul and ol
  9. margin-bottom: 0;
  10. #border-radius(@list-group-border-radius);
  11. }
  12. // Interactive list items
  13. //
  14. // Use anchor or button elements instead of `li`s or `div`s to create interactive
  15. // list items. Includes an extra `.active` modifier class for selected items.
  16. .list-group-item-action {
  17. width: 100%; // For `<button>`s (anchors become 100% by default though)
  18. color: @list-group-action-color;
  19. text-align: inherit; // For `<button>`s (anchors inherit)
  20. // Hover state
  21. #hover-focus({
  22. z-index: 1; // Place hover/focus items above their siblings for proper border styling
  23. color: @list-group-action-hover-color;
  24. text-decoration: none;
  25. background-color: @list-group-hover-bg;
  26. });
  27. &:active {
  28. color: @list-group-action-active-color;
  29. background-color: @list-group-action-active-bg;
  30. }
  31. }
  32. // Individual list items
  33. //
  34. // Use on `li`s or `div`s within the `.list-group` parent.
  35. .list-group-item {
  36. position: relative;
  37. display: block;
  38. padding: @list-group-item-padding-y @list-group-item-padding-x;
  39. // LESS PORT: Less doesn’t strip “empty” property values so we have to check for a value first.
  40. & when not (@list-group-color = ~"") { color: @list-group-color; }
  41. & when not (@link-decoration = none) { text-decoration: none; }
  42. background-color: @list-group-bg;
  43. border: @list-group-border-width solid @list-group-border-color;
  44. &:first-child {
  45. #border-top-radius(inherit);
  46. }
  47. &:last-child {
  48. #border-bottom-radius(inherit);
  49. }
  50. &.disabled,
  51. &:disabled {
  52. color: @list-group-disabled-color;
  53. pointer-events: none;
  54. background-color: @list-group-disabled-bg;
  55. }
  56. // Include both here for `<a>`s and `<button>`s
  57. &.active {
  58. z-index: 2; // Place active items above their siblings for proper border styling
  59. color: @list-group-active-color;
  60. background-color: @list-group-active-bg;
  61. border-color: @list-group-active-border-color;
  62. }
  63. & + & {
  64. border-top-width: 0;
  65. &.active {
  66. margin-top: -@list-group-border-width;
  67. border-top-width: @list-group-border-width;
  68. }
  69. }
  70. }
  71. // Horizontal
  72. //
  73. // Change the layout of list group items from vertical (default) to horizontal.
  74. //@each $breakpoint in map-keys($grid-breakpoints) {
  75. // @include media-breakpoint-up($breakpoint) {
  76. // $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
  77. //
  78. // .list-group-horizontal#{$infix} {
  79. // flex-direction: row;
  80. //
  81. // .list-group-item {
  82. // &:first-child {
  83. // @include border-bottom-left-radius($list-group-border-radius);
  84. // @include border-top-right-radius(0);
  85. // }
  86. //
  87. // &:last-child {
  88. // @include border-top-right-radius($list-group-border-radius);
  89. // @include border-bottom-left-radius(0);
  90. // }
  91. //
  92. // &.active {
  93. // margin-top: 0;
  94. // }
  95. //
  96. // & + .list-group-item {
  97. // border-top-width: $list-group-border-width;
  98. // border-left-width: 0;
  99. //
  100. // &.active {
  101. // margin-left: -$list-group-border-width;
  102. // border-left-width: $list-group-border-width;
  103. // }
  104. // }
  105. // }
  106. // }
  107. // }
  108. //}
  109. each(map-keys(@grid-breakpoints), #(@breakpoint) {
  110. #media-breakpoint-up(@breakpoint, {
  111. @infix: breakpoint-infix(@breakpoint, @grid-breakpoints);
  112. .list-group-horizontal@{infix} {
  113. flex-direction: row;
  114. > .list-group-item {
  115. &:first-child {
  116. #border-bottom-left-radius(@list-group-border-radius);
  117. #border-top-right-radius(0);
  118. }
  119. &:last-child {
  120. #border-top-right-radius(@list-group-border-radius);
  121. #border-bottom-left-radius(0);
  122. }
  123. &.active {
  124. margin-top: 0;
  125. }
  126. + .list-group-item {
  127. border-top-width: @list-group-border-width;
  128. border-left-width: 0;
  129. &.active {
  130. margin-left: -@list-group-border-width;
  131. border-left-width: @list-group-border-width;
  132. }
  133. }
  134. }
  135. }
  136. });
  137. });
  138. // Flush list items
  139. //
  140. // Remove borders and border-radius to keep list group items edge-to-edge. Most
  141. // useful within other components (e.g., cards).
  142. .list-group-flush {
  143. #border-radius(0);
  144. > .list-group-item {
  145. border-width: 0 0 @list-group-border-width;
  146. &:last-child {
  147. border-bottom-width: 0;
  148. }
  149. }
  150. }
  151. // Contextual variants
  152. //
  153. // Add modifier classes to change text and background color on individual items.
  154. // Organizationally, this must come after the `:hover` states.
  155. each(@theme-colors, #(@value, @color) {
  156. #list-group-item-variant(@color, theme-color-level(@color, -9), theme-color-level(@color, 6));
  157. });