{"id":23014858,"url":"https://github.com/pierreburel/sass-em","last_synced_at":"2025-06-14T18:07:40.929Z","repository":{"id":28989616,"uuid":"32516294","full_name":"pierreburel/sass-em","owner":"pierreburel","description":"Sass function and mixin to convert px in em.","archived":false,"fork":false,"pushed_at":"2023-11-10T21:19:06.000Z","size":257,"stargazers_count":22,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-15T18:14:21.770Z","etag":null,"topics":["css","em","sass","scss"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pierreburel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-03-19T10:59:04.000Z","updated_at":"2024-01-29T17:49:51.000Z","dependencies_parsed_at":"2023-11-10T22:24:04.409Z","dependency_job_id":"b3ce904a-55e5-4da3-893b-2f70ba51aa90","html_url":"https://github.com/pierreburel/sass-em","commit_stats":{"total_commits":16,"total_committers":3,"mean_commits":5.333333333333333,"dds":0.5625,"last_synced_commit":"461914ffbad26c56245a29d2936ca247da82555b"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/pierreburel/sass-em","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreburel%2Fsass-em","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreburel%2Fsass-em/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreburel%2Fsass-em/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreburel%2Fsass-em/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pierreburel","download_url":"https://codeload.github.com/pierreburel/sass-em/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pierreburel%2Fsass-em/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259860406,"owners_count":22922987,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","em","sass","scss"],"created_at":"2024-12-15T11:10:16.006Z","updated_at":"2025-06-14T18:07:40.897Z","avatar_url":"https://github.com/pierreburel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sass-em [![Node.js CI](https://github.com/pierreburel/sass-em/actions/workflows/node.js.yml/badge.svg)](https://github.com/pierreburel/sass-em/actions/workflows/node.js.yml)\n\nSass function and mixin to convert px in em.\n\n## Breaking changes\n\n- **3.0**: changed default function name when imported globally (`@use \"rem\" as *;` or `@import \"sass-rem\";`) to `em-convert` to match [sass-rem](https://github.com/pierreburel/sass-rem), as [CSS now use `rem()` for calculating the remainder](https://developer.mozilla.org/en-US/docs/Web/CSS/rem). It shouldn't change anything if you used Sass Modules introduced in 2.0 (`em.convert`).\n\n- **2.0**: now using [Sass Modules](https://sass-lang.com/blog/the-module-system-is-launched), using `@use` and `em` is renamed to `em.convert`. You could still use `@import` with no changes (see usage below), but **if you need LibSass/node-sass and Ruby Sass support (both deprecated), you should stay on 1.0** (which works fine) or use the [PostCSS](https://github.com/pierreburel/postcss-em) version.\n\n---\n\n## Installation\n\nInstall with [Yarn](https://yarnpkg.com/) or [npm](https://www.npmjs.com/):\n\n* `yarn add sass-em`\n* `npm install sass-em`\n\n---\n\n## Usage\n\nThe `em.convert` function takes at least 2 parameters: the value(s) (px, mixed) and the context (px).\nThere can be multiple values (eg. multiple box shadow), but **the last parameter must be the context**.\n\nThe `em.convert` mixin takes only 2 parameters: the properties (map of `property: value`) and the context (px). It can be used to convert the values of multiple properties with the same context.\n\nImport in your project depending of your setup:\n\n```scss\n@use \"em\";\n// or @use \"~sass-em\" as em;\n// or @use \"../node_modules/sass-em\" as em;\n\n$base-font-size: 16px;\n$h1-font-size: 24px;\n\n.demo {\n  font-size: em.convert($h1-font-size, $base-font-size); // Simple\n  border-bottom: em.convert(1px solid black, $h1-font-size); // Shorthand\n  box-shadow: em.convert(0 0 2px #ccc, inset 0 0 5px #eee, $h1-font-size); // Multiple values\n  // Multiple properties\n  @include em.convert((\n    margin: 20px 5%,\n    padding: 10px\n  ), $h1-font-size);\n}\n```\n\nWill output :\n\n```css\n.demo {\n  font-size: 1.5em;\n  border-bottom: 0.0416666667em solid black;\n  box-shadow: 0 0 0.0833333333em #ccc, inset 0 0 0.2083333333em #eee;\n  margin: 0.8333333333em 5%;\n  padding: 0.4166666667em;\n}\n```\n\n## Namespace\n\nYou can change the namespace when importing and use `em` function and mixin instead of `convert`:\n\n```scss\n@use \"em\" as to; // Because why not?\n\n.demo {\n  font-size: to.em(24px, 16px);\n}\n```\n\nOr you can even load the library globally (but beware of conflicts, avoided by the idea of modules):\n\n```scss\n@use \"em\" as *;\n\n.demo {\n  font-size: em-convert(24px, 16px);\n}\n```\n\n---\n\n## Legacy import\n\nIf you don't want to use Sass Modules, you can still use `@import` with `em-convert` function and mixin:\n\n```scss\n@import \"sass-em\";\n\n.demo {\n  font-size: em-convert(24px);\n}\n```\n\n---\n\n## See also\n\n- PostCSS version: https://github.com/pierreburel/postcss-em\n- `sass-rem`: https://github.com/pierreburel/sass-rem\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierreburel%2Fsass-em","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpierreburel%2Fsass-em","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierreburel%2Fsass-em/lists"}