_list-group.scss 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. color: $list-group-action-hover-color;
  22. text-decoration: none;
  23. background-color: $list-group-hover-bg;
  24. }
  25. &:active {
  26. color: $list-group-action-active-color;
  27. background-color: $list-group-action-active-bg;
  28. }
  29. }
  30. // Individual list items
  31. //
  32. // Use on `li`s or `div`s within the `.list-group` parent.
  33. .list-group-item {
  34. position: relative;
  35. display: block;
  36. padding: $list-group-item-padding-y $list-group-item-padding-x;
  37. // Place the border on the list items and negative margin up for better styling
  38. margin-bottom: -$list-group-border-width;
  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. margin-bottom: 0;
  46. @include border-bottom-radius($list-group-border-radius);
  47. }
  48. @include hover-focus {
  49. z-index: 1; // Place hover/active items above their siblings for proper border styling
  50. text-decoration: none;
  51. }
  52. &.disabled,
  53. &:disabled {
  54. color: $list-group-disabled-color;
  55. background-color: $list-group-disabled-bg;
  56. }
  57. // Include both here for `<a>`s and `<button>`s
  58. &.active {
  59. z-index: 2; // Place active items above their siblings for proper border styling
  60. color: $list-group-active-color;
  61. background-color: $list-group-active-bg;
  62. border-color: $list-group-active-border-color;
  63. }
  64. }
  65. // Flush list items
  66. //
  67. // Remove borders and border-radius to keep list group items edge-to-edge. Most
  68. // useful within other components (e.g., cards).
  69. .list-group-flush {
  70. .list-group-item {
  71. border-right: 0;
  72. border-left: 0;
  73. @include border-radius(0);
  74. }
  75. &:first-child {
  76. .list-group-item:first-child {
  77. border-top: 0;
  78. }
  79. }
  80. &:last-child {
  81. .list-group-item:last-child {
  82. border-bottom: 0;
  83. }
  84. }
  85. }
  86. // Contextual variants
  87. //
  88. // Add modifier classes to change text and background color on individual items.
  89. // Organizationally, this must come after the `:hover` states.
  90. @each $color, $value in $theme-colors {
  91. @include list-group-item-variant($color, theme-color-level($color, -9), theme-color-level($color, 6));
  92. }