Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@uifabric/merge-styles

microsoft126.6kMIT7.20.2TypeScript support: included

Style loading utilities.

readme

@uifabric/merge-styles

The merge-styles library provides utilities for loading styles through javascript. It is designed to make it simple to style components through javascript. It generates css classes, rather than using inline styling, to ensure we can use css features like pseudo selectors (:hover) and parent/child selectors (media queries).

The library was built for speed and size; the entire package is 2.62k gzipped. It has no dependencies other than tslib.

Simple usage:

import { mergeStyles, mergeStyleSets } from '@uifabric/merge-styles';

// Produces 'css-0' class name which can be used anywhere
mergeStyles({ background: 'red' });

// Produces a class map for a bunch of rules all at once
mergeStyleSets({
  root: { background: 'red' },
  child: { background: 'green' }
});

// Returns { root: 'root-0', child: 'child-1' }

Both utilities behave similar to a deep Object.assign; you can collapse many objects down into one class name or class map.

The basic idea is to provide tools which can take in one or more css styling objects representing the styles for a given element, and return a single class name. If the same set of styling is passed in, the same name returns and nothing is re-registered.

Motivation

Defining rules at runtime has a number of benefits over traditional build time staticly produced css:

  • Only register classes that are needed, when they're needed, reducing the overall selector count and improving TTG.

  • Dynamically create new class permutations based on contextual theming requirements. (Use a different theme inside of a DIV without downloading multiple copies of the css rule definitions.)

  • Use JavaScript to define the class content (using utilities like color converters, or reusing constant numbers becomes possible.)

  • Allow control libraries to merge customized styling in with their rules, avoiding complexities like css selector specificity.

  • Simplify RTL processing; lefts become rights in RTL, in the actual rules. No complexity like html[dir=rtl] prefixes necessary, which alleviates unexpected specificity bugs. (You can use /* noflip */ comments to avoid flipping if needed.)

  • Reduce bundle size. Automatically handles vendor prefixing, unit providing, RTL flipping, and margin/padding expansion (e.g. margin will automatically expand out to margin TRBL, so that we avoid specificity problems when merging things together.)

  • Reduce the build time overhead of running through CSS preprocessors.

  • TypeScript type safety; spell "background" wrong and get build breaks.

What tradeoffs are there? Are there downsides to using JavaScript to process styling?

In static solutions, there is very little runtime evaluation required; everything is injected as-is. Things like auto prefixing and language specific processing like sass mixins are all evaluated at build time.

In runtime styling, much of this is evaluated in the browser, so you are paying a cost in doing this. However, with performance optimizations like memoization, you can minimize this quite a bit, and you gain all of the robustness enumerated above.

API

The api surfaces consists of 3 methods and a handful of interfaces:

mergeStyles(..args[]: IStyle[]): string - Takes in one or more style objects, merges them in the right order, and produces a single css class name which can be injected into any component.

mergeStyleSets(...args[]: IStyleSet[]): { [key: string]: string } - Takes in one or more style set objects, each consisting of a set of areas, each which will produce a class name. Using this is analogous to calling mergeStyles for each property in the object, but ensures we maintain the set ordering when multiple style sets are merged.

concatStyleSets(...args[]: IStyleSet[]): IStyleSet - In some cases you simply need to combine style sets, without actually generating class names (it is costs in performance to generate class names.) This tool returns a single set merging many together.

concatStyleSetsWithProps(props: {}, ...args[]: IStyleSet[]): IStyleSet - Similar to concatStyleSet except that style sets which contain functional evaluation of styles are evaluated prior to concatenating.

Example:

const result = concatStyleSetsWithProps<IFooProps, IFooStyles>(
  { foo: 'bar' },
  (props: IFooProps) => ({ root: { background: props.foo } }),
  (props: IFooProps) => ({ root: { color: props.foo } }),
);

Vocabulary

A style object represents the collection of css rules, except that the names are camelCased rather than kebab-cased. Example:

let style = {
  backgroundColor: 'red',
  left: 42,
};

Additionally, style objects can contain selectors:

let style = {
  backgroundColor: 'red',
  ':hover': {
    backgroundColor: 'blue';
  },
  '.parent &': { /* parent selector */ },
  '& .child': { /* child selector */ }
};

A style set represents a map of area to style object. When building a component, you need to generate a class name for each element that requires styling. You would define this in a style set.

let styleSet = {
  root: { background: 'red' },
  button: { margin: 42 },
};

Basic usage

When building a component, you will need a style set map of class names to inject into your elements' class attributes.

The recommended pattern is to provide the classnames in a separate function, typically in a separate file ComponentName.classNames.ts.

import { IStyle, mergeStyleSets } from '@uifabric/merge-styles';

export interface IComponentClassNames {
  root: string;
  button: string;
  buttonIcon: string;
}

export const getClassNames = (): IComponentClassNames => {
  return mergeStyleSets({
    root: {
      background: 'red',
    },

    button: {
      backgroundColor: 'green',
    },

    buttonIcon: {
      margin: 10,
    },
  });
};

The class map can then be used in a component:

import { getClassNames } from './MyComponent.classNames';

export const MyComponent = () => {
  let { root, button, buttonIcon } = getClassNames();

  return (
    <div className={root}>
      <button className={button}>
        <i className={buttonIcon} />
      </button>
    </div>
  );
};

Selectors

Basic pseudo-selectors (:hover, :active, etc)

Custom selectors can be defined within IStyle definitions:

{
  background: 'red',
  ':hover': {
    background: 'green'
  }
}

By default, the rule will be appended to the current selector scope. That is, in the above scenario, there will be 2 rules inserted when using mergeStyles:

.css-0 {
  background: red;
}
.css-0:hover {
  background: green;
}

Parent/child selectors

In some cases, you may need to use parent or child selectors. To do so, you can define a selector from scratch and use the & character to represent the generated class name. When using the &, the current scope is ignored. Example:

{
  // selector relative to parent
  '.ms-Fabric--isFocusVisible &': {
    background: 'red'
  }

  // selector for child
  '& .child' {
    background: 'green'
  }
}

This would register the rules:

.ms-Fabric--isFocusVisible .css-0 {
  background: red;
}
.css-0 .child {
  background: green;
}

Global selectors

While we suggest avoiding global selectors, there are some cases which make sense to register things globally. Keep in mind that global selectors can't be guaranteed unique and may suffer from specificity problems and versioning issues in the case that two different versions of your library get rendered on the page.

To register a selector globally, wrap it in a :global() wrapper:

{
  ':global(button)': {
    overflow: 'visible'
  }
}

Media and feature queries

Media queries can be applied via selectors. For example, this style will produce a class which has a red background when above 600px, and green when at or below 600px:

mergeStyles({
  background: 'red',
  '@media(max-width: 600px)': {
    background: 'green',
  },
  '@supports(display: grid)': {
    display: 'grid',
  },
});

Produces:

.css-0 {
  background: red;
}

@media (max-width: 600px) {
  .css-0 {
    background: green;
  }
}

@supports (display: grid) {
  .css-0 {
    display: grid;
  }
}

Referencing child elements within the mergeStyleSets scope

One important concept about mergeStyleSets is that it produces a map of class names for the given elements:

mergeStyleSets({
  root: { background: 'red' }
  thumb: { background: 'green' }
});

Produces:

.root-0 {
  background: red;
}
.thumb-1 {
  background: green;
}

In some cases, you may need to alter a child area by interacting with the parent. For example, when the parent is hovered, change the child background. We recommend using global, non-changing static classnames to target the parent elements:

const classNames = {
  root: 'Foo-root',
  child: 'Foo-child',
};

mergeStyleSets({
  root: [classNames.root, { background: 'lightgreen' }],

  child: [
    classNames.child,
    {
      [`.${classNames.root}:hover &`]: {
        background: 'green',
      },
    },
  ],
});

The important part here is that the selector does not have any mutable information. In the example above, if classNames.root were dynamic, it would require the rule to be re-registered when it mutates, which would be a performance hit.

Custom class names

By default when using mergeStyles, class names that are generated will use the prefix css- followed by a number, creating unique rules where needed. For example, the first class name produced will be 'css-0'.

When using mergeStyleSets, class names automatically use the area name as the prefix.

Merging rules like:

mergeStyleSets({ a: { ... }, b: { ... } })

Will produce the class name map:

{ a: 'a-0', b: 'b-1' }

If you'd like to override the default prefix in either case, you can pass in a displayName to resolve this:

{
  displayName: 'MyComponent',
  background: 'red'
}

This generates:

.MyComponent-0 {
  background: red;
}

Managing conditionals and states

Style objects can be represented by a simple object, but also can be an array of the objects. The merge functions will handle arrays and merge things together in the given order. They will also ignore falsey values, allowing you to conditionalize the results.

In the following example, the root class generated will be different depending on the isToggled state:

export const getClassNames = (isToggled: boolean): IComponentClassNames => {
  return mergeStyleSets({
    root: [
      {
        background: 'red',
      },
      isToggled && {
        background: 'green',
      },
    ],
  });
};

RTL support

By default, nearly all of the major rtl-sensitive CSS properties will be auto flipped when the dir="rtl" flag is present on the HTML tag of the page.

There are some rare scenarios (linear-gradients, etc) which are not flipped, for the sake of keeping the bundle size to a minimum. If there are missing edge cases, please submit a PR to address.

In rare condition where you want to avoid auto flipping, you can annotate the rule with the @noflip directive:

mergeStyles({
  left: '42px @noflip',
});

Optimizing for performance

Resolving the class names on every render can be an unwanted expense especially in hot spots where things are rendered frequently. To optimize, we recommend 2 guidelines:

  1. For your getClassNames function, flatten all input parameters into simple immutable values. This helps the memoizeFunction utility to cache the results based on the input.

  2. Use the memoizeFunction function from the @uifabric/utilities package to cache the results, given a unique combination of inputs. Example:

import { memoizeFunction } from '@uifabric/utilities';

export const getClassNames = memoizeFunction((isToggled: boolean) => {
  return mergeStyleSets({
    // ...
  });
});

Registering fonts

Registering font faces example:

import { fontFace } from '@uifabric/merge-styles';

fontFace({
  fontFamily: `"Segoe UI"`,
  src: `url("//cdn.com/fontface.woff2) format(woff2)`,
  fontWeight: 'normal',
});

Note that in cases like fontFamily you may need to embed quotes in the string as shown above.

Registering keyframes

Registering animation keyframes example:

import { keyframes, mergeStyleSets } from '@uifabric/merge-styles';

let fadeIn = keyframes({
  from: {
    opacity: 0,
  },
  to: {
    opacity: 1,
  },
});

export const getClassNames = () => {
  return mergeStyleSets({
    root: {
      animationName: fadeIn,
    },
  });
};

Controlling where styles are injected

By default merge-styles will initially inject a style element into the document head as the first node and then append and new style elements as next sibling to the previous one added.

In some cases you may want to control where styles are injected to ensure some stylesheets are more specific than others. To do this, you can add a placeholder style element in the head with data-merge-styles attribute:

<head>
  <style data-merge-styles></style>
</head>

Merge styles will ensure that any generated styles are added after the placeholder.

Server-side rendering

You can import renderStatic method from the /lib/server entry to render content and extract the css rules that would have been registered, as a string.

Example:

import { renderStatic } from '@uifabric/merge-styles/lib/server';

let { html, css } = renderStatic(() => {
  return ReactDOM.renderToString(...);
});

Caveats for server-side rendering:

  • Rules registered in the file scope of code won't be re-evaluated and therefore won't be included in the result. Try to avoid using classes which are not evaluated at runtime.

For example:

const rootClass = mergeStyles({ background: 'red' });
const App = () => <div className={rootClass} />;

// App will render, but "rootClass" is a string which won't get re-evaluated in this call.
renderStatic(() => ReactDOM.renderToString(<App/>);
  • Using memoizeFunction around rule calculation can help with excessive rule recalc performance overhead.

  • Rehydration on the client may result in mismatched rules. You can apply a namespace on the server side to ensure there aren't name collisions.

Working with content security policy (CSP)

Some content security policies prevent style injection without a nonce. To set the nonce used by merge-styles:

Stylesheet.getInstance().setConfig({
  cspSettings: { nonce: 'your nonce here' },
});

If you're working inside a Fluent UI React app (formerly Office UI Fabric React), this setting can also be applied using the global window.FabricConfig.mergeStyles.cspSettings. Note that this must be set before any Fluent UI React code is loaded, or it may not be applied properly.

window.FabricConfig = {
  mergeStyles: {
    cspSettings: { nonce: 'your nonce here' },
  },
};

changelog

Change Log - @uifabric/merge-styles

This log was last generated on Mon, 31 Oct 2022 12:21:19 GMT and should not be manually modified.

7.20.2

Mon, 31 Oct 2022 12:21:19 GMT Compare changes

Patches

  • Add some logic to stylesheet that will do a simple append instead of using insert before if the reference node isn't actually a child of the document head. (PR #25387 by gcox@microsoft.com)

7.20.1

Fri, 30 Sep 2022 21:44:22 GMT Compare changes

Patches

  • getVendorSettings.js file was leading to app crash if userAgent was null. Have added a null check for userAgent (PR #25035 by arujain@microsoft.com)

7.19.0

Tue, 15 Sep 2020 12:26:06 GMT Compare changes

Minor changes

  • Exporting additional typings, updated auto-unit generation to not prefix the default unit (px) on css custom properties. (PR #14985 by dzearing@hotmail.com)

7.18.0

Fri, 28 Aug 2020 12:29:20 GMT Compare changes

Minor changes

7.17.0

Tue, 25 Aug 2020 12:36:19 GMT Compare changes

Minor changes

  • Deprecating the selectors node. While it still works, you no longer need to wrap selectors within it. Just inline them next to the other styles. (PR #14707 by dzearing@hotmail.com)

7.16.1

Mon, 13 Jul 2020 23:14:39 GMT Compare changes

Patches

7.16.0

Tue, 30 Jun 2020 12:33:36 GMT Compare changes

Minor changes

7.15.0

Thu, 25 Jun 2020 12:50:17 GMT Compare changes

Minor changes

  • Loosening typings to allow for css variables. Removing kebab casing for css values which start with dashes. (PR #13751 by dzearing@hotmail.com)

7.14.0

Fri, 15 May 2020 20:33:16 GMT Compare changes

Minor changes

  • Addressing another typing issue found by TS 3.9.2 which is now catching scenarios which were shallow partials but should have been deep partials. (PR #13185 by dzearing@microsoft.com)

7.13.0

Fri, 15 May 2020 00:07:39 GMT Compare changes

Minor changes

7.12.0

Mon, 11 May 2020 12:36:34 GMT Compare changes

Minor changes

7.11.4

Fri, 08 May 2020 12:35:40 GMT Compare changes

Patches

7.11.3

Thu, 07 May 2020 01:06:55 GMT Compare changes

Patches

7.11.2

Tue, 05 May 2020 12:34:22 GMT Compare changes

Patches

7.11.0

Fri, 17 Apr 2020 12:34:08 GMT Compare changes

Minor changes

7.10.0

Thu, 16 Apr 2020 04:01:45 GMT Compare changes

Minor changes

Patches

7.8.11

Mon, 30 Mar 2020 19:10:08 GMT

Patches

Patches

Patches

  • Replace OfficeDev/office-ui-fabric-react with microsoft/fluentui (elcraig@microsoft.com)

    7.8.3

    Wed, 22 Jan 2020 12:36:43 GMT

Patches

  • Documentation: Added note to merge-styles readme about working with content security policy (CSP). (elcraig@microsoft.com)

    7.8.2

    Fri, 17 Jan 2020 02:32:17 GMT

Patches

  • Update tslib minver to first version containing __spreadArrays helper due to changes in how TS emits spreads. (jagore@microsoft.com)

    7.8.1

    Fri, 08 Nov 2019 12:30:07 GMT

Patches

  • Add px units to flexBasis styling by default. Remove existing styling usage where it had no effect before this PR. (jagore@microsoft.com)

    7.8.0

    Mon, 21 Oct 2019 12:33:23 GMT

Minor changes

  • Add -ms-overflow-style as a valid CSS property (unindented@gmail.com)

    7.7.0

    Thu, 26 Sep 2019 12:32:32 GMT

Minor changes

  • mergeStyles and mergeStyleSets have a companion method which accepts options for setting RTL (jdh@microsoft.com)

    7.6.0

    Fri, 20 Sep 2019 12:34:28 GMT

Minor changes

  • Adding concatStyleSetsWithProps to help resolve stylesets that are functional, resolving with props. (dzearing@microsoft.com)

    7.5.2

    Thu, 12 Sep 2019 12:34:15 GMT

Patches

  • Build the kebabRules map instead of shipping it (mark@thedutchies.com)

    7.5.1

    Wed, 04 Sep 2019 04:09:58 GMT

Patches

Minor changes

  • merge-styles: Collapsing comma delimited selectors to make styles easy to define for multiple matches. (dzearing@hotmail.com)

    7.4.1

    Fri, 23 Aug 2019 12:35:28 GMT

Patches

7.4.0

Tue, 13 Aug 2019 12:31:12 GMT

Minor changes

  • Removing deprecated and buggy "$" reference feature, which has added perf overhead in all scenarios, replacing with simpler regex to replace ampersands in selectors with classnames. (dzearing@microsoft.com)

7.3.0

Wed, 07 Aug 2019 12:32:28 GMT

Minor changes

7.2.0

Wed, 17 Jul 2019 18:58:57 GMT

Minor changes

  • Changed initial default style injection to insert at the start of head by default, rather than at the end. This lets user specified stylesheets have preference by default, but also added support to insert styles in a specific part of the HEAD element. Just create a placeholder <style data-merge-styles/> element within the head, and styles will be injected after that placeholder. (vibraga@microsoft.com)

Patches

  • Adding @types/react and @types/react-dom to package.json that have peer dependencies on react and react-dom. (makotom@microsoft.com)

7.1.1

Mon, 01 Jul 2019 18:51:42 GMT

Patches

  • Re-use style nodes in IE11 to prevent unpredictable cascading

7.1.0

Thu, 27 Jun 2019 18:25:04 GMT

Minor changes

  • Add fontDisplay to IFontFace

Patches

  • Reducing runtime overhead on kebab parsing. Reducing some concatStyleSets overhead.

7.0.2

Fri, 14 Jun 2019 12:26:30 GMT

Patches

  • Fix missing assets in production build.

7.0.1

Thu, 13 Jun 2019 00:24:48 GMT

Patches

  • Initial release of Fabric 7

6.19.0

Wed, 12 Jun 2019 00:42:26 GMT

Minor changes

  • Changin borderBottomLeftRadius, borderBottomRightRadius, borderTopLeftRadius and borderTopRightRadius to be of type ICSSPixelUnitRule, like borderRadius, instead of type string.

6.18.1

Tue, 11 Jun 2019 12:21:35 GMT

Patches

  • upgrade to api-extractor 7.1.6

6.18.0

Wed, 05 Jun 2019 12:22:30 GMT

Minor changes

  • Fix TS 3.5 typing issues.

6.17.4

Tue, 21 May 2019 12:20:44 GMT

Patches

  • Use shared demo app bootstrapping code

6.17.3

Tue, 14 May 2019 07:50:30 GMT

Patches

  • Update Fabric assets link

6.17.2

Wed, 08 May 2019 12:37:40 GMT

Patches

  • merge-styles: Removing typeof window call in getInstance to remove an IE11 memory leak.

6.17.1

Thu, 02 May 2019 12:36:35 GMT

Patches

  • a new line is added to the end of the api-extractor.json file

6.17.0

Mon, 15 Apr 2019 12:33:42 GMT

Minor changes

  • Inject nonce to style tag if specified in csp settings in FabricConfig.

6.16.5

Thu, 11 Apr 2019 12:37:10 GMT

Patches

  • Documentation: add @docCategory inline tags

6.16.4

Tue, 02 Apr 2019 00:38:15 GMT

Patches

  • Use ^ ranges instead of >=

6.16.3

Mon, 01 Apr 2019 12:37:03 GMT

Patches

  • Deleting .api.ts file.

6.16.2

Wed, 27 Mar 2019 12:34:02 GMT

Patches

  • update API file
  • update api file generated by api-extractor 7

6.16.1

Fri, 08 Mar 2019 13:32:10 GMT

Patches

  • Fix selector in a mergeStyleSets Readme example

6.16.0

Fri, 01 Mar 2019 13:33:08 GMT

Minor changes

  • Some references to "process" have been removed to help with tree shaking.

6.15.2

Wed, 30 Jan 2019 13:36:21 GMT

Patches

  • Fix bug where multiple selectors in :global() would not be processed correctly

6.15.1

Wed, 23 Jan 2019 22:53:13 GMT

Patches

  • Allow :global to be used in more scenarios than just ":global(selector)"
  • Use CSS object-fit in the Image component in capable browsers

6.15.0

Thu, 15 Nov 2018 13:36:22 GMT

Minor changes

  • DevExp: get rid of const enum so the library is compatible with Typescript's isolatedModule compilation mode

6.14.0

Tue, 13 Nov 2018 13:30:53 GMT

Minor changes

  • strokeLinecap added to IRawStyles.

6.13.0

Thu, 08 Nov 2018 04:17:34 GMT

Minor changes

  • Fixes #6975: adds ability for mergestyles to handle commas in selectors

6.11.0

Fri, 26 Oct 2018 12:32:35 GMT

Minor changes

  • Add api-extractor.json

6.10.4

Wed, 24 Oct 2018 12:28:58 GMT

Patches

  • IRawStyleBase: Replace string type on display property with a more specific type of possible values.

6.10.3

Mon, 22 Oct 2018 12:29:57 GMT

Patches

  • Added 'stretch' as valid value for justifyContent in IRawStyleBase.

6.10.2

Thu, 18 Oct 2018 20:22:36 GMT

Patches

  • Update api-extractor

6.10.1

Mon, 15 Oct 2018 12:29:12 GMT

Patches

  • IStyleSet: Now uses a form that works better in TS 2.8 and does not require TS 3.0 to work. Thanks Nimelrian!
  • Adding css grid properties to fill out the spec

6.10.0

Thu, 11 Oct 2018 23:13:31 GMT

Minor changes

  • Enable api-extractor task for merge-styles

6.9.4

Mon, 08 Oct 2018 12:24:15 GMT

Patches

  • Moving tslint/prettier dependencies

6.9.3

Mon, 01 Oct 2018 12:27:24 GMT

Patches

  • Prettier cleanup

6.9.2

Fri, 28 Sep 2018 12:27:38 GMT

Patches

  • Ignoring registering rules which are undefined.

6.9.1

Fri, 21 Sep 2018 14:25:46 GMT

Patches

  • Adding a version stamp file

6.9.0

Thu, 20 Sep 2018 12:25:33 GMT

Minor changes

  • Adding support for feature queries in selectors.

6.8.4

Thu, 13 Sep 2018 17:38:04 GMT

Patches

  • Added some missing styles. mix-blend-mode plus some padding-inline-*

6.8.3

Wed, 05 Sep 2018 10:29:25 GMT

Patches

  • Improve a DX issue with IProcessedStyleSet typings. (issue #6124)

6.8.2

Wed, 29 Aug 2018 10:28:42 GMT

Patches

  • The IProcessedStyleSet type now correctly infers the types of subComponentStyles properties.

6.8.1

Tue, 28 Aug 2018 10:23:58 GMT

Patches

  • Adds missing CSS property values for 'align-self' in IRawStyle type definition and corrects CSS property values for 'justify-self' in 'IRawStyle'

6.8.0

Mon, 27 Aug 2018 10:27:43 GMT

Minor changes

  • Adds support for 'justifySelf' which is needed to align items in CSS Grid.

6.7.0

Mon, 30 Jul 2018 10:27:11 GMT

Minor changes

  • Change IProcessedStyleSet typings to be easier to consume - subcomponentStyles is now always present so consumers do not have to check for presence even when it is fully expected that it is there.

Patches

  • formatting change

6.6.0

Thu, 26 Jul 2018 10:28:51 GMT

Minor changes

  • Add resize rule to IRawStyleBase.

6.5.1

Thu, 19 Jul 2018 21:25:32 GMT

Patches

  • mergeStyleSet is able to take falsey values again and handle it correctly in all cases.

6.5.0

Wed, 18 Jul 2018 10:25:50 GMT

Minor changes

  • Add support for style functions and improve documentation/typings.

6.4.0

Fri, 13 Jul 2018 21:32:37 GMT

Minor changes

  • Reverting the TypeScript bump, to un

6.2.3

Tue, 10 Jul 2018 21:54:07 GMT

Patches

  • Refining the merge-styles fix from yesterday to check for ownerDocument changes, which is a more correct comparison to work around the Chrome "window not resetting" issue.

6.2.2

Tue, 10 Jul 2018 05:05:15 GMT

Patches

  • If the singleton Stylesheet instance originated from another window, reset the instance. Workaround for an unexplained Chrome issue where the singleton was still accessible after a page refresh.

6.2.1

Wed, 20 Jun 2018 10:25:55 GMT

Patches

  • Prettier fixes

6.2.0

Thu, 07 Jun 2018 16:35:34 GMT

Minor changes

  • Minor changes to improve server side rendering.

6.0.2

Tue, 05 Jun 2018 00:44:30 GMT

Patches

  • Added Prettier

6.0.1

Mon, 04 Jun 2018 10:16:13 GMT

Patches

  • Updating react typings.

6.0.0

Wed, 30 May 2018 22:05:03 GMT

Breaking changes

5.17.1

Wed, 23 May 2018 10:28:50 GMT

Patches

  • Added missing merge-styles background-size typing

5.17.0

Thu, 26 Apr 2018 10:12:34 GMT

Minor changes

  • Add animation to IRawStyleBase for use in style sets.

5.16.1

Wed, 25 Apr 2018 05:32:09 GMT

Patches

  • merge-styles: style elements which are created on the fly now "bunch" together, avoiding unpredictability in specificity.

5.16.0

Mon, 23 Apr 2018 10:24:54 GMT

Minor changes

  • Updating how keyframe classes are cached to aid with jest snapshot testing.

Patches

  • Updating documentation.

5.15.2

Tue, 17 Apr 2018 18:47:11 GMT

Patches

  • mergeStyles: rules are now registered in separate styling objects, improving performance significantly.

5.15.1

Mon, 16 Apr 2018 10:23:26 GMT

Patches

  • Removing module entry temporarily. (Will be added back in 6.0.)

5.15.0

Tue, 10 Apr 2018 17:37:28 GMT

Minor changes

  • Add backgroundClip property definition.

5.14.1

Fri, 06 Apr 2018 10:25:55 GMT

Patches

  • mergeStyles: flipping RTL at runtime now resets the keys.

5.14.0

Sun, 25 Mar 2018 03:08:03 GMT

Minor changes

  • Updating to webpack 4 for producting bundles. Adding appropriate module and sideEffects fl

5.13.0

Fri, 02 Mar 2018 11:25:35 GMT

Minor changes

  • Upgrade to TypeScript 2.7.2

5.12.2

Wed, 21 Feb 2018 11:12:11 GMT

Patches

  • Adding test coverage for media queries.

5.12.1

Fri, 16 Feb 2018 11:23:29 GMT

Patches

  • mergeStyles: setting fill-opacity as unitless.

5.12.0

Wed, 14 Feb 2018 22:10:50 GMT

Minor changes

  • mergeStyles: Adding support to register selectors globally. Use :global(rule) as the selector to ensure that the unique className is not prepended in the output. See merge-styles README.md for more details.

5.11.2

Wed, 07 Feb 2018 11:23:59 GMT

Patches

  • Adjusting rtl flipping logic to be more resilient to invalid styling.

5.11.1

Tue, 06 Feb 2018 11:14:36 GMT

Patches

  • [provideUnits] Add line-height to ignore

5.11.0

Thu, 25 Jan 2018 11:23:06 GMT

Minor changes

  • Change maxHeight/maxFontSize to CSSPixelUnitRule (number and string)

5.10.1

Wed, 17 Jan 2018 11:11:25 GMT

Patches

  • Fix styles with undefined values being added to document (#3700)

5.10.0

Thu, 28 Dec 2017 11:23:50 GMT

Minor changes

  • Added a setting to Stylesheet which allows overriding the default prefix

5.9.0

Sat, 16 Dec 2017 05:07:22 GMT

Minor changes

  • Updated build to newest React version and typings. Updated tests and made various tweaks to the code to remove React warnings and keep Enzyme

5.8.1

Mon, 11 Dec 2017 11:24:05 GMT

Patches

  • Fixing issues where child variables in selectors would not expand correctly. Also fixing a case where the same static class registered in two different sets will not show up multiple times in the result from mergeStyleSets.

5.8.0

Fri, 01 Dec 2017 11:11:16 GMT

Minor changes

  • Adding onInsertNode callback and adjusting appendChild method for injecting styles to not cause flashes.

5.7.0

Wed, 29 Nov 2017 11:24:05 GMT

Minor changes

  • Updating TypeScript to 2.6.2.

5.6.0

Fri, 10 Nov 2017 17:09:36 GMT

Minor changes

  • Adding the ability to append style content rather than inject using insertRule, for special cases.

5.5.1

Thu, 02 Nov 2017 18:20:18 GMT

Patches

  • When selectors use previously registered class names as values, they are now correctly auto expanded.

5.5.0

Tue, 24 Oct 2017 10:21:08 GMT

Minor changes

  • Adding stroke css property to typings.

5.4.2

Fri, 20 Oct 2017 18:42:08 GMT

Patches

  • Calling mergeStyles with strings containing space delimited class names was not expanding merge-styles generated class names in the final merge. Fixed so that it does.

5.4.1

Tue, 17 Oct 2017 17:17:41 GMT

Patches

  • mergeStyles: in RTL we were seeing exceptions with registering opacity: 0 in keyframes. This has been addressed and a test has been added to cover the case.

5.4.0

Fri, 13 Oct 2017 04:00:17 GMT

Minor changes

  • Fixes to support media queries.

Patches

  • Adding data-merge-styles attribute to the style element so that it can be uniquely identified.

5.3.3

Fri, 13 Oct 2017 01:36:02 GMT

Patches

  • Adding data-merge-styles attribute to the style element so that it can be uniquely identified.

5.3.2

Mon, 09 Oct 2017 10:08:09 GMT

Patches

  • Add test for autoexpand

5.3.1

Fri, 06 Oct 2017 10:18:41 GMT

Patches

  • TSConfig: update to use preserveConstEnums so that certain builds s ystems don't break when importing const enums

5.3.0

Thu, 05 Oct 2017 10:17:42 GMT

Minor changes

  • Adding selector support to target child class names that were generated in the same mergeStyleSets set.

5.2.0

Sat, 30 Sep 2017 01:26:37 GMT

Minor changes

  • Found that adding false to the list of accepted typings in mergeStyleSets was breaking type safety. Removed it.

5.1.0

Fri, 29 Sep 2017 10:20:24 GMT

Minor changes

  • The mergeStyleSets method's type safety was not correct. Now with significantly better type safety.