_list-group.scss 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. }
  11. // Interactive list items
  12. //
  13. // Use anchor or button elements instead of `li`s or `div`s to create interactive
  14. // list items. Includes an extra `.active` modifier class for selected items.
  15. .list-group-item-action {
  16. width: 100%; // For `<button>`s (anchors become 100% by default though)
  17. color: $list-group-action-color;
  18. text-align: inherit; // For `<button>`s (anchors inherit)
  19. // Hover state
  20. @include hover-focus() {
  21. z-index: 1; // Place hover/focus items above their siblings for proper border styling
  22. color: $list-group-action-hover-color;
  23. text-decoration: none;
  24. background-color: $list-group-hover-bg;
  25. }
  26. &:active {
  27. color: $list-group-action-active-color;
  28. background-color: $list-group-action-active-bg;
  29. }
  30. }
  31. // Individual list items
  32. //
  33. // Use on `li`s or `div`s within the `.list-group` parent.
  34. .list-group-item {
  35. position: relative;
  36. display: block;
  37. padding: $list-group-item-padding-y $list-group-item-padding-x;
  38. color: $list-group-color;
  39. background-color: $list-group-bg;
  40. border: $list-group-border-width solid $list-group-border-color;
  41. &:first-child {
  42. @include border-top-radius($list-group-border-radius);
  43. }
  44. &:last-child {
  45. @include border-bottom-radius($list-group-border-radius);
  46. }
  47. &.disabled,
  48. &:disabled {
  49. color: $list-group-disabled-color;
  50. pointer-events: none;
  51. background-color: $list-group-disabled-bg;
  52. }
  53. // Include both here for `<a>`s and `<button>`s
  54. &.active {
  55. z-index: 2; // Place active items above their siblings for proper border styling
  56. color: $list-group-active-color;
  57. background-color: $list-group-active-bg;
  58. border-color: $list-group-active-border-color;
  59. }
  60. & + & {
  61. border-top-width: 0;
  62. &.active {
  63. margin-top: -$list-group-border-width;
  64. border-top-width: $list-group-border-width;
  65. }
  66. }
  67. }
  68. // Horizontal
  69. //
  70. // Change the layout of list group items from vertical (default) to horizontal.
  71. @each $breakpoint in map-keys($grid-breakpoints) {
  72. @include media-breakpoint-up($breakpoint) {
  73. $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
  74. .list-group-horizontal#{$infix} {
  75. flex-direction: row;
  76. .list-group-item {
  77. &:first-child {
  78. @include border-bottom-left-radius($list-group-border-radius);
  79. @include border-top-right-radius(0);
  80. }
  81. &:last-child {
  82. @include border-top-right-radius($list-group-border-radius);
  83. @include border-bottom-left-radius(0);
  84. }
  85. &.active {
  86. margin-top: 0;
  87. }
  88. & + .list-group-item {
  89. border-top-width: $list-group-border-width;
  90. border-left-width: 0;
  91. &.active {
  92. margin-left: -$list-group-border-width;
  93. border-left-width: $list-group-border-width;
  94. }
  95. }
  96. }
  97. }
  98. }
  99. }
  100. // Flush list items
  101. //
  102. // Remove borders and border-radius to keep list group items edge-to-edge. Most
  103. // useful within other components (e.g., cards).
  104. .list-group-flush {
  105. .list-group-item {
  106. border-right-width: 0;
  107. border-left-width: 0;
  108. @include border-radius(0);
  109. &:first-child {
  110. border-top-width: 0;
  111. }
  112. }
  113. &:last-child {
  114. .list-group-item:last-child {
  115. border-bottom-width: 0;
  116. }
  117. }
  118. }
  119. // Contextual variants
  120. //
  121. // Add modifier classes to change text and background color on individual items.
  122. // Organizationally, this must come after the `:hover` states.
  123. @each $color, $value in $theme-colors {
  124. @include list-group-item-variant($color, theme-color-level($color, -9), theme-color-level($color, 6));
  125. }