_list-group.scss 2.72 KB
Newer Older
Mark Otto's avatar
Mark Otto committed
1
2
3
// Base class
//
// Easily usable on <ul>, <ol>, or <div>.
Mark Otto's avatar
Mark Otto committed
4

Mark Otto's avatar
Mark Otto committed
5
.list-group {
6
7
  display: flex;
  flex-direction: column;
8

Mark Otto's avatar
Mark Otto committed
9
  // No need to set list-style: none; since .list-group-item is block level
10
  padding-left: 0; // reset padding because ul and ol
11
  margin-bottom: 0;
Mark Otto's avatar
Mark Otto committed
12
13
}

Mark Otto's avatar
Mark Otto committed
14

15
16
17
18
19
20
21
// Interactive list items
//
// Use anchor or button elements instead of `li`s or `div`s to create interactive
// list items. Includes an extra `.active` modifier class for selected items.

.list-group-item-action {
  width: 100%; // For `<button>`s (anchors become 100% by default though)
22
  color: $list-group-action-color;
23
24
25
26
  text-align: inherit; // For `<button>`s (anchors inherit)

  // Hover state
  @include hover-focus {
27
    color: $list-group-action-hover-color;
28
29
30
31
32
    text-decoration: none;
    background-color: $list-group-hover-bg;
  }

  &:active {
33
34
    color: $list-group-action-active-color;
    background-color: $list-group-action-active-bg;
35
36
37
38
  }
}


Mark Otto's avatar
Mark Otto committed
39
// Individual list items
Mark Otto's avatar
Mark Otto committed
40
41
//
// Use on `li`s or `div`s within the `.list-group` parent.
Mark Otto's avatar
Mark Otto committed
42
43
44

.list-group-item {
  position: relative;
Mark Otto's avatar
Mark Otto committed
45
  display: block;
46
  padding: $list-group-item-padding-y $list-group-item-padding-x;
Mark Otto's avatar
Mark Otto committed
47
  // Place the border on the list items and negative margin up for better styling
48
  margin-bottom: -$list-group-border-width;
Mark Otto's avatar
Mark Otto committed
49
  background-color: $list-group-bg;
50
  border: $list-group-border-width solid $list-group-border-color;
Mark Otto's avatar
Mark Otto committed
51

52
  &:first-child {
Mark Otto's avatar
Mark Otto committed
53
    @include border-top-radius($list-group-border-radius);
54
  }
55

56
57
  &:last-child {
    margin-bottom: 0;
Mark Otto's avatar
Mark Otto committed
58
    @include border-bottom-radius($list-group-border-radius);
59
  }
Mark Otto's avatar
Mark Otto committed
60

61
62
63
64
65
66
67
68
  @include hover-focus {
    text-decoration: none;
  }

  &.disabled,
  &:disabled {
    color: $list-group-disabled-color;
    background-color: $list-group-disabled-bg;
69
  }
Mark Otto's avatar
Mark Otto committed
70

71
  // Include both here for `<a>`s and `<button>`s
72
  &.active {
73
74
75
    z-index: 2; // Place active items above their siblings for proper border styling
    color: $list-group-active-color;
    background-color: $list-group-active-bg;
76
    border-color: $list-group-active-border-color;
77
  }
Mark Otto's avatar
Mark Otto committed
78
}
79

80
81
82
83
84
85

// Flush list items
//
// Remove borders and border-radius to keep list group items edge-to-edge. Most
// useful within other components (e.g., cards).

86
87
.list-group-flush {
  .list-group-item {
88
89
    border-right: 0;
    border-left: 0;
90
91
    border-radius: 0;
  }
92
93
94
95
96
97
98
99
100
101
102
103

  &:first-child {
    .list-group-item:first-child {
      border-top: 0;
    }
  }

  &:last-child {
    .list-group-item:last-child {
      border-bottom: 0;
    }
  }
104
105
106
}


Mark Otto's avatar
Mark Otto committed
107
108
109
110
111
// Contextual variants
//
// Add modifier classes to change text and background color on individual items.
// Organizationally, this must come after the `:hover` states.

112
113
114
@each $color, $value in $theme-colors {
  @include list-group-item-variant($color, theme-color-level($color, -9), theme-color-level($color, 6));
}