Skip to main content

The Getter Function for Maps

Don't use map-get($colors, "primary") everywhere. It’s verbose and ugly. Write a simple wrapper function instead.

SCSS
$colors: (
  "primary": #3498db,
  "secondary": #2ecc71
);

@function color($key) {
  @return map-get($colors, $key);
}

.button { background: color("primary"); }