_list-group.scss 2.95 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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// 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)

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

  &:active {
    color: $list-group-link-active-color;
    background-color: $list-group-link-active-bg;
  }
}


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;
45
46
47
  display: flex;
  flex-flow: row wrap;
  align-items: center;
48
  padding: $list-group-item-padding-y $list-group-item-padding-x;
Mark Otto's avatar
Mark Otto committed
49
  // Place the border on the list items and negative margin up for better styling
50
  margin-bottom: -$list-group-border-width;
Mark Otto's avatar
Mark Otto committed
51
  background-color: $list-group-bg;
52
  border: $list-group-border-width solid $list-group-border-color;
Mark Otto's avatar
Mark Otto committed
53

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

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

63
64
65
66
67
68
69
70
71
  @include hover-focus {
    text-decoration: none;
  }

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

74
  // Include both here for `<a>`s and `<button>`s
75
  &.active {
76
77
78
79
    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;
80
  }
Mark Otto's avatar
Mark Otto committed
81
}
82

83
84
85
86
87
88

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

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

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

  &:last-child {
    .list-group-item:last-child {
      border-bottom: 0;
    }
  }
107
108
109
}


Mark Otto's avatar
Mark Otto committed
110
111
112
113
114
// 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
115
116
117
118
@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);