_list-group.scss 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. // Place the border on the list items and negative margin up for better styling
  39. margin-bottom: -$list-group-border-width;
  40. color: $list-group-color;
  41. background-color: $list-group-bg;
  42. border: $list-group-border-width solid $list-group-border-color;
  43. &:first-child {
  44. @include border-top-radius($list-group-border-radius);
  45. }
  46. &:last-child {
  47. margin-bottom: 0;
  48. @include border-bottom-radius($list-group-border-radius);
  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. // Horizontal
  65. //
  66. // Change the layout of list group items from vertical (default) to horizontal.
  67. @each $breakpoint in map-keys($grid-breakpoints) {
  68. @include media-breakpoint-up($breakpoint) {
  69. $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
  70. .list-group-horizontal#{$infix} {
  71. flex-direction: row;
  72. .list-group-item {
  73. margin-right: -$list-group-border-width;
  74. margin-bottom: 0;
  75. &:first-child {
  76. @include border-left-radius($list-group-border-radius);
  77. @include border-top-right-radius(0);
  78. }
  79. &:last-child {
  80. margin-right: 0;
  81. @include border-right-radius($list-group-border-radius);
  82. @include border-bottom-left-radius(0);
  83. }
  84. }
  85. }
  86. }
  87. }
  88. // Flush list items
  89. //
  90. // Remove borders and border-radius to keep list group items edge-to-edge. Most
  91. // useful within other components (e.g., cards).
  92. .list-group-flush {
  93. .list-group-item {
  94. border-right: 0;
  95. border-left: 0;
  96. @include border-radius(0);
  97. &:last-child {
  98. margin-bottom: -$list-group-border-width;
  99. }
  100. }
  101. &:first-child {
  102. .list-group-item:first-child {
  103. border-top: 0;
  104. }
  105. }
  106. &:last-child {
  107. .list-group-item:last-child {
  108. margin-bottom: 0;
  109. border-bottom: 0;
  110. }
  111. }
  112. }
  113. // Contextual variants
  114. //
  115. // Add modifier classes to change text and background color on individual items.
  116. // Organizationally, this must come after the `:hover` states.
  117. @each $color, $value in $theme-colors {
  118. @include list-group-item-variant($color, theme-color-level($color, -9), theme-color-level($color, 6));
  119. }