Accoutrement 2.1.1

$breakpoints (map)

scss
$breakpoints: () !default;

Establish a map of named breakpoints.

If you have Accoutrement-Scale installed, you can use the scale syntax for describing size-relationships and adjustments – and even reference $sizes as though they are $breakpoints. Otherwise, the map should contain only valid CSS length values.

Since 0.1.0:

  • BREAKING: Uses the new shared map syntax, for internal references and adjustments

Examples

scss defining breakpoints
$breakpoints: (
  'small': 30em,
  'medium': 45em,
);
scss using accoutrement-scale
$breakpoints: (
  'small': 30em ('convert-units': 'browser-ems'),
  'medium': '#small' ('times': 1.5),
);

Related

@function break()

Return a breakpoint from the $breakpoint map, or the accoutrement-scale $sizes map if it’s available.

Since 1.0.0:

  • NEW: Accepts $do map argument, for on-the-fly adjustments
  • NEW: Accepts $source map argument, for custom breakpoint source-palette
  • NEW: Accepts $scale boolean argument, to turn off access to scale plugin $sizes map

Parameters & Return

$break: (string)

The name or value of a breakpoint

$do: null (map | null)

A map of function/ratio adjustments to run on the returned value

$source: $breakpoints (map)

Optional accoutrement-format map of breakpoints to use as the origin palette

$scale: true (boolean)

By default, we merge in any $sizes available from the scale plugin – making both $breakpoints and $sizes keys available

@return (length)

The retrieved value of a named breakpoint

@error

$break is not a valid length or keyword

Requires

@function get-token()

@function _a_error() [private]

$sizes (map)

Used By

@mixin below()

@mixin above()

@mixin between()

@mixin below()

Generate a max–<width/height> query, for styling elements below the given viewport width.

To help with overlapping min/max queries, we remove 1px (or 0.01em) from every max value by default. You can adjust that setting to adjust min values or avoid adjustments using the global $adjust-query-overlap setting.

Since 2.0.0:

  • BREAKING: min/max adjustments applied to all units (not only px/em/rem)
  • NEW: min/max adjustments respect $adjust-query-overlap global setting

Parameters

$max: (length | string)

The name of a documented breakpoint/size, or an arbitarty length to use in the query.

$prop: 'width' ('width' | 'height')

The property (width or height) to test against, for a result of e.g. (max-width: 30em).

Examples

scss
@include below(30em) {
  html { background: red; }
}
css compiled
@media (max-width: 29.99em) {
  html {
    background: red;
  }
}
scss
$breakpoints: ('red': 30em);

@include below('red') {
  html { background: red; }
}
css compiled
@media (max-width: 29.99em) {
  html {
    background: red;
  }
}

Requires

@function break()

@function _a_nudge-query() [private]

@mixin above()

Generate a min-<width/height> query, for styling elements above the given viewport width.

To help with overlapping min/max queries, we remove 1px (or 0.01em) from max values by default. You can adjust that setting to adjust min values or avoid adjustments using the global $adjust-query-overlap setting.

Since 2.0.0:

  • BREAKING: min/max adjustments applied to all units (not only px/em/rem)
  • NEW: min/max adjustments respect $adjust-query-overlap global setting

Parameters

$min: (length | string)

The name of a documented breakpoint/size, or an arbitrary length to use in the query.

$prop: 'width' ('width' | 'height')

The property (width or height) to test against, for a result of e.g. (min-width: 30em).

Examples

scss
@include above(50em) {
  html { background: green; }
}
css compiled
@media (min-width: 50em) {
  html {
    background: green;
  }
}
scss
$breakpoints: ('green': 50em);

@include above('green') {
  html { background: green; }
}
css compiled
@media (min-width: 50em) {
  html {
    background: green;
  }
}

Requires

@function break()

@function _a_nudge-query() [private]

@mixin between()

Generate a min-and-max-<width/height> query, for styling elements between given viewport widths.

To help with overlapping min/max queries, we remove 1px (or 0.01em) from every max value by default. You can adjust that setting to adjust min values or avoid adjustments using the global $adjust-query-overlap setting.

Since 2.0.0:

  • BREAKING: min/max adjustments applied to all units (not only px/em/rem)
  • NEW: min/max adjustments respect $adjust-query-overlap global setting

Parameters

$min: (length | string)

The name of a documented breakpoint/size, or an arbitarty length to use as a minimum in the query.

$max: (length | string)

The name of a documented breakpoint/size, or an arbitarty length to use as a maximum in the query.

$prop: 'width' ('width' | 'height')

The property (width or height) to test against, for a result of e.g. (min-width: 30em).

Examples

scss
@include between(30em, 50em) {
  html { background: yellow; }
}
css compiled
@media (min-width: 30em) and (max-width: 49.99em) {
  html {
    background: yellow;
  }
}
scss
$breakpoints: (
  'red': 30em,
  'green': 50em,
);

@include between('red', 'green') {
  html { background: yellow; }
}
css compiled
@media (min-width: 30em) and (max-width: 49.99em) {
  html {
    background: yellow;
  }
}

Requires

@function break()

@function _a_nudge-query() [private]

$adjust-query-overlap ('min' | 'max' | false)

scss
$adjust-query-overlap: 'max' !default;

When using both min- and max- media-queries, you will often get a 1px or 1em overlap where neither or both queries are applied. In order to avoid that, we nudge the max- value down by default. Set this variable to min to nudge min- values up, or false to keep both min and max values un-adjusted,

Since 2.0.0:

  • NEW: Allows you to override global max-adjustment default

Related