Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit b996b7f

Browse files
authored
feat(chips): Create mixin to customize chip margins (#2277)
1 parent 06e39b1 commit b996b7f

File tree

5 files changed

+37
-1
lines changed

5 files changed

+37
-1
lines changed

packages/mdc-chips/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ To customize the colors of any part of the chip, use the following mixins.
9494

9595
Mixin | Description
9696
--- | ---
97+
`mdc-chip-set-spacing($gap-size)` | Customizes the amount of space between each chip in the set
9798
`mdc-chip-corner-radius($radius)` | Customizes the corner radius for a chip
9899
`mdc-chip-fill-color-accessible($color)` | Customizes the background fill color for a chip, and updates the chip's ink and ripple color to meet accessibility standards
99100
`mdc-chip-fill-color($color)` | Customizes the background fill color for a chip
@@ -104,6 +105,8 @@ Mixin | Description
104105
`mdc-chip-stroke-style($style)` | Customizes the border stroke style for a chip
105106
`mdc-chip-stroke-color($color)` | Customizes the border stroke color for a chip
106107

108+
> _NOTE_: `mdc-chip-set-spacing` also sets the amount of space between a chip and the edge of the set it's contained in.
109+
107110
> _NOTE_: `mdc-chip-ink-color` also updates the chip's text ink color for _hover_ and _activated_ states, and updates the ripple opacity of the chip in the _activated_ state.
108111
109112
### `MDCChip` and `MDCChipSet`

packages/mdc-chips/_mixins.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,11 @@
8787
padding-left: $horizontal-padding-value;
8888
border-width: $width;
8989
}
90+
91+
@mixin mdc-chip-set-spacing($gap-size) {
92+
padding: $gap-size / 2;
93+
94+
.mdc-chip {
95+
margin: $gap-size / 2;
96+
}
97+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// Copyright 2017 Google Inc. All Rights Reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
@import "../mixins";
18+
19+
.mdc-chip-set {
20+
@include mdc-chip-set-spacing(8px);
21+
22+
display: flex;
23+
flex-wrap: wrap;
24+
box-sizing: border-box;
25+
}

packages/mdc-chips/chip/mdc-chip.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
display: inline-flex;
3333
position: relative;
3434
align-items: center;
35-
margin: 4px;
3635
padding: $mdc-chip-vertical-padding $mdc-chip-horizontal-padding;
3736
cursor: pointer;
3837
outline: none;

packages/mdc-chips/mdc-chips.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
//
1717

1818
@import "./chip/mdc-chip";
19+
@import "./chip-set/mdc-chip-set";

0 commit comments

Comments
 (0)