Implant style tags where you need them.
yarn add style-implantnpm install style-implantimport styleImplant from 'style-implant';
const css = `
body {
margin: 0;
}
`;
const options = {
attributes: { 'data-implanted': '💉' },
insertAt: 'top',
preserveOrder: true,
};
styleImplant(css, options);{
attributes?: {string: string};
insertAt?: string = 'bottom';
preserveOrder?: boolean = false;
}attributes: Takes an object where the keys are attribute names and the values are the attribute values.insertAt: When'top'style tags will be implanted in the top of the head rather than the bottom. Warning: This will reverse the order in which tags load as the newest tag will always be first instead of last.preserveOrder: When enable multiple style tags will be implanted in order from oldest to newest within the same parent element. This option is disabled by default to match the output ofstyle-injectbut it's reccomended that you enable it for a better experience. Future versions may enable this by default.
style-implant was designed to be a drop in replacement for style-inject. All versions until v0.4.0 of style-implant will not cause breaking changes for previous users of style-inject. These versions will only add more options. This package improves on style-inject by adding critical options, TypeScript support, and tests!
Based on style-inject by EGOIST
Licensed under the MIT license
© 2021 Ivo Ilić