_list-group.scss 3.67 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
8
9
10
  @if $enable-flex {
    display: flex;
    flex-direction: column;
  }

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

Mark Otto's avatar
Mark Otto committed
16

Mark Otto's avatar
Mark Otto committed
17
// Individual list items
Mark Otto's avatar
Mark Otto committed
18
19
//
// Use on `li`s or `div`s within the `.list-group` parent.
Mark Otto's avatar
Mark Otto committed
20
21

.list-group-item {
22
23
24
25
26
27
28
  @if $enable-flex {
    display: flex;
    flex-flow: row wrap;
    align-items: center;
  } @else {
    display: block;
  }
29
  
Mark Otto's avatar
Mark Otto committed
30
  position: relative;
31
  padding: $list-group-item-padding-y $list-group-item-padding-x;
Mark Otto's avatar
Mark Otto committed
32
  // Place the border on the list items and negative margin up for better styling
33
  margin-bottom: -$list-group-border-width;
Mark Otto's avatar
Mark Otto committed
34
  background-color: $list-group-bg;
35
  border: $list-group-border-width solid $list-group-border-color;
Mark Otto's avatar
Mark Otto committed
36

37
  &:first-child {
Mark Otto's avatar
Mark Otto committed
38
    @include border-top-radius($list-group-border-radius);
39
  }
40

41
42
  &:last-child {
    margin-bottom: 0;
Mark Otto's avatar
Mark Otto committed
43
    @include border-bottom-radius($list-group-border-radius);
44
  }
Mark Otto's avatar
Mark Otto committed
45

46
47
48
49
50
51
52
53
54
55
56
57
58
  &.disabled {
    @include plain-hover-focus {
      color: $list-group-disabled-color;
      cursor: $cursor-disabled;
      background-color: $list-group-disabled-bg;

      // Force color to inherit for custom content
      .list-group-item-heading {
        color: inherit;
      }
      .list-group-item-text {
        color: $list-group-disabled-text-color;
      }
59
60
    }
  }
Mark Otto's avatar
Mark Otto committed
61

62
63
64
65
  &.active {
    @include plain-hover-focus {
      z-index: 2; // Place active items above their siblings for proper border styling
      color: $list-group-active-color;
66
      text-decoration: none; // Repeat here because it inherits global a:hover otherwise
67
68
69
70
71
72
73
74
75
76
77
78
      background-color: $list-group-active-bg;
      border-color: $list-group-active-border;

      // Force color to inherit for custom content
      .list-group-item-heading,
      .list-group-item-heading > small,
      .list-group-item-heading > .small {
        color: inherit;
      }
      .list-group-item-text {
        color: $list-group-active-text-color;
      }
79
80
    }
  }
Mark Otto's avatar
Mark Otto committed
81
}
82

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

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

  &:last-child {
    .list-group-item:last-child {
      border-bottom: 0;
    }
  }
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
}


// 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)
  color: $list-group-link-color;
  text-align: inherit; // For `<button>`s (anchors inherit)

  .list-group-item-heading {
    color: $list-group-link-heading-color;
  }

  // Hover state
  @include hover-focus {
    color: $list-group-link-hover-color;
    text-decoration: none;
    background-color: $list-group-hover-bg;
  }
}

Mark Otto's avatar
Mark Otto committed
126
127
128
129
130
131

// Contextual variants
//
// Add modifier classes to change text and background color on individual items.
// Organizationally, this must come after the `:hover` states.

Mark Otto's avatar
Mark Otto committed
132
133
134
135
@include list-group-item-variant(success, $state-success-bg, $state-success-text);
@include list-group-item-variant(info, $state-info-bg, $state-info-text);
@include list-group-item-variant(warning, $state-warning-bg, $state-warning-text);
@include list-group-item-variant(danger, $state-danger-bg, $state-danger-text);
Mark Otto's avatar
Mark Otto committed
136
137


138
// Custom content options
Mark Otto's avatar
Mark Otto committed
139
140
//
// Extra classes for creating well-formatted content within `.list-group-item`s.
141
142
143

.list-group-item-heading {
  margin-top: 0;
144
  margin-bottom: $list-group-item-heading-margin-bottom;
145
146
147
148
149
}
.list-group-item-text {
  margin-bottom: 0;
  line-height: 1.3;
}