_list-group.scss 3.16 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
6
.list-group {
  // No need to set list-style: none; since .list-group-item is block level
7
  padding-left: 0; // reset padding because ul and ol
8
  margin-bottom: 0;
Mark Otto's avatar
Mark Otto committed
9
10
}

Mark Otto's avatar
Mark Otto committed
11

Mark Otto's avatar
Mark Otto committed
12
// Individual list items
Mark Otto's avatar
Mark Otto committed
13
14
//
// Use on `li`s or `div`s within the `.list-group` parent.
Mark Otto's avatar
Mark Otto committed
15
16
17
18

.list-group-item {
  position: relative;
  display: block;
19
  padding: .75rem 1.25rem;
Mark Otto's avatar
Mark Otto committed
20
  // Place the border on the list items and negative margin up for better styling
21
  margin-bottom: -$list-group-border-width;
Mark Otto's avatar
Mark Otto committed
22
  background-color: $list-group-bg;
23
  border: $list-group-border-width solid $list-group-border-color;
Mark Otto's avatar
Mark Otto committed
24

25
26
  // Round the first and last items
  &:first-child {
Mark Otto's avatar
Mark Otto committed
27
    @include border-top-radius($list-group-border-radius);
28
29
30
  }
  &:last-child {
    margin-bottom: 0;
Mark Otto's avatar
Mark Otto committed
31
    @include border-bottom-radius($list-group-border-radius);
32
  }
33
}
Mark Otto's avatar
Mark Otto committed
34

35
36
37
38
39
40
.list-group-flush {
  .list-group-item {
    border-radius: 0;
  }
}

41

Mark Otto's avatar
Mark Otto committed
42
// Interactive list items
Mark Otto's avatar
Mark Otto committed
43
//
Mark Otto's avatar
Mark Otto committed
44
45
// 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.
Mark Otto's avatar
Mark Otto committed
46

Mark Otto's avatar
Mark Otto committed
47
48
a.list-group-item,
button.list-group-item {
49
  width: 100%;
Mark Otto's avatar
Mark Otto committed
50
  color: $list-group-link-color;
51
  text-align: inherit;
52

53
  .list-group-item-heading {
Mark Otto's avatar
Mark Otto committed
54
    color: $list-group-link-heading-color;
55
  }
Mark Otto's avatar
Mark Otto committed
56

57
  // Hover state
58
  @include hover-focus {
Mark Otto's avatar
Mark Otto committed
59
    color: $list-group-link-hover-color;
60
    text-decoration: none;
Mark Otto's avatar
Mark Otto committed
61
    background-color: $list-group-hover-bg;
62
  }
63
}
Mark Otto's avatar
Mark Otto committed
64

65
.list-group-item {
66
  // Disabled state
67
68
69
70
71
72
73
74
75
76
77
78
79
  &.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;
      }
80
81
    }
  }
Mark Otto's avatar
Mark Otto committed
82

83
  // Active class on item itself, not parent
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
  &.active {
    @include plain-hover-focus {
      z-index: 2; // Place active items above their siblings for proper border styling
      color: $list-group-active-color;
      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;
      }
100
101
    }
  }
Mark Otto's avatar
Mark Otto committed
102
}
103

Mark Otto's avatar
Mark Otto committed
104
105
106
107
108
109

// 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
110
111
112
113
@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
114
115


116
// Custom content options
Mark Otto's avatar
Mark Otto committed
117
118
//
// Extra classes for creating well-formatted content within `.list-group-item`s.
119
120
121
122
123
124
125
126
127

.list-group-item-heading {
  margin-top: 0;
  margin-bottom: 5px;
}
.list-group-item-text {
  margin-bottom: 0;
  line-height: 1.3;
}