{"id":19653027,"url":"https://github.com/csstools/postcss-media-fn","last_synced_at":"2025-04-28T17:31:11.675Z","repository":{"id":46193419,"uuid":"77880309","full_name":"csstools/postcss-media-fn","owner":"csstools","description":"Use media() to assign responsive values to a property","archived":true,"fork":false,"pushed_at":"2021-11-08T11:48:05.000Z","size":71,"stargazers_count":15,"open_issues_count":1,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-25T05:06:16.650Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://jonathantneal.github.io/postcss-media-fn/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/csstools.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-03T03:20:25.000Z","updated_at":"2024-12-27T18:36:14.000Z","dependencies_parsed_at":"2022-08-26T01:23:07.588Z","dependency_job_id":null,"html_url":"https://github.com/csstools/postcss-media-fn","commit_stats":null,"previous_names":["jonathantneal/postcss-media-fn"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csstools%2Fpostcss-media-fn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csstools%2Fpostcss-media-fn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csstools%2Fpostcss-media-fn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csstools%2Fpostcss-media-fn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csstools","download_url":"https://codeload.github.com/csstools/postcss-media-fn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251217957,"owners_count":21554285,"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":[],"created_at":"2024-11-11T15:12:57.455Z","updated_at":"2025-04-28T17:31:11.659Z","avatar_url":"https://github.com/csstools.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Media() [\u003cimg src=\"https://postcss.github.io/postcss/logo.svg\" alt=\"PostCSS Logo\" width=\"90\" height=\"90\" align=\"right\"\u003e][postcss]\n\n[![NPM Version][npm-img]][npm-url]\n[![Build Status][cli-img]][cli-url]\n[![Licensing][lic-img]][lic-url]\n[![Gitter Chat][git-img]][git-url]\n\n[Media()] lets you use the `media()` function to assign responsive values to a declaration, following the [CSS Media Expressions] specification.\n\n```css\n/* before */\n\nh1 {\n  font-size: media(\n    16px,\n    (min-width:  600px) 20px,\n    (min-width: 1000px) 40px,\n    (min-width: 1400px) 60px\n  );\n}\n\n\n/* after */\n\nh1 {\n  font-size: 16px;\n}\n\n@media (min-width: 600px) {\n  h1 {\n    font-size: 20px;\n  }\n}\n\n@media (min-width: 1000px) {\n  h1 {\n    font-size: 40px;\n  }\n}\n\n@media (min-width: 1400px) {\n  h1 {\n    font-size: 60px;\n  }\n}\n```\n\n## Usage\n\nAdd [Media()] to your build tool:\n\n```bash\nnpm install postcss-media-fn --save-dev\n```\n\n#### Node\n\n```js\nrequire('postcss-media-fn').process(YOUR_CSS, { /* options */ });\n```\n\n#### PostCSS\n\nAdd [PostCSS] to your build tool:\n\n```bash\nnpm install postcss --save-dev\n```\n\nLoad [Media()] as a PostCSS plugin:\n\n```js\npostcss([\n  require('postcss-media-fn')({ /* options */ })\n]).process(YOUR_CSS, /* options */);\n```\n\n#### Gulp\n\nAdd [Gulp PostCSS] to your build tool:\n\n```bash\nnpm install gulp-postcss --save-dev\n```\n\nEnable [Media()] within your Gulpfile:\n\n```js\nvar postcss = require('gulp-postcss');\n\ngulp.task('css', function () {\n  return gulp.src('./src/*.css').pipe(\n    postcss([\n      require('postcss-media-fn')({ /* options */ })\n    ])\n  ).pipe(\n    gulp.dest('.')\n  );\n});\n```\n\n#### Grunt\n\nAdd [Grunt PostCSS] to your build tool:\n\n```bash\nnpm install grunt-postcss --save-dev\n```\n\nEnable [Media()] within your Gruntfile:\n\n```js\ngrunt.loadNpmTasks('grunt-postcss');\n\ngrunt.initConfig({\n  postcss: {\n    options: {\n      use: [\n        require('postcss-media-fn')({ /* options */ })\n      ]\n    },\n    dist: {\n      src: '*.css'\n    }\n  }\n});\n```\n\n[cli-url]: https://github.com/csstools/postcss-media-fn/actions/workflows/ci.yaml\n[cli-img]: https://github.com/csstools/postcss-media-fn/actions/workflows/ci.yaml/badge.svg\n[git-url]: https://gitter.im/postcss/postcss\n[git-img]: https://img.shields.io/badge/chat-gitter-blue.svg\n[lic-url]: LICENSE.md\n[lic-img]: https://img.shields.io/npm/l/postcss-media-fn.svg\n[npm-url]: https://www.npmjs.com/package/postcss-media-fn\n[npm-img]: https://img.shields.io/npm/v/postcss-media-fn.svg\n\n[CSS Media Expressions]: https://jonathantneal.github.io/media-expressions-spec/\n[Gulp PostCSS]: https://github.com/postcss/gulp-postcss\n[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss\n[Media()]: https://github.com/jonathantneal/postcss-media-fn\n[PostCSS]: https://github.com/postcss/postcss\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsstools%2Fpostcss-media-fn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsstools%2Fpostcss-media-fn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsstools%2Fpostcss-media-fn/lists"}