{"id":19653037,"url":"https://github.com/csstools/postcss-register-property","last_synced_at":"2025-04-28T17:31:15.058Z","repository":{"id":57328415,"uuid":"140495851","full_name":"csstools/postcss-register-property","owner":"csstools","description":"Register properties in CSS","archived":true,"fork":false,"pushed_at":"2018-10-25T13:39:19.000Z","size":100,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-21T21:38:50.887Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://jonathantneal.github.io/postcss-register-property/","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":"2018-07-10T23:00:17.000Z","updated_at":"2024-09-29T09:57:09.000Z","dependencies_parsed_at":"2022-09-21T01:40:55.575Z","dependency_job_id":null,"html_url":"https://github.com/csstools/postcss-register-property","commit_stats":null,"previous_names":["jonathantneal/postcss-register-property"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csstools%2Fpostcss-register-property","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csstools%2Fpostcss-register-property/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csstools%2Fpostcss-register-property/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csstools%2Fpostcss-register-property/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csstools","download_url":"https://codeload.github.com/csstools/postcss-register-property/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251216467,"owners_count":21554005,"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:58.894Z","updated_at":"2025-04-28T17:31:15.043Z","avatar_url":"https://github.com/csstools.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PostCSS Register Property [\u003cimg src=\"https://postcss.github.io/postcss/logo.svg\" alt=\"PostCSS\" width=\"90\" height=\"90\" align=\"right\"\u003e][postcss]\n\n[![NPM Version][npm-img]][npm-url]\n[![Build Status][cli-img]][cli-url]\n[![Support Chat][git-img]][git-url]\n\n[PostCSS Register Property] lets you register properties in CSS.\n\n```pcss\n@property --highlight-color {\n  inherits: true;\n  initial-value: red;\n  syntax: \"\u003ccolor\u003e\";\n}\n\n@property --gap-spacing {\n  inherits: false;\n  initial-value: 1em;\n  syntax: \"\u003clength-percentage\u003e\";\n}\n```\n\nThese properties are transformed into JSON.\n\n```json\n[\n  {\n    \"name\": \"--highlight-color\",\n    \"inherits\": true,\n    \"initialValue\": \"red\",\n    \"syntax\": \"\u003ccolor\u003e\"\n  },\n  {\n    \"name\": \"--gap-spacing\",\n    \"initialValue\": \"1em\",\n    \"syntax\": \"\u003clength-percentage\u003e\"\n  }\n]\n```\n\nThese properties can be imported and registered in a browser.\n\n```js\nimport properties from './styles.css.properties.json';\n\nif (window.CSS \u0026\u0026 CSS.registerProperty) {\n  for (const descriptor of properties) {\n    CSS.registerProperty(descriptor);\n  }\n}\n```\n\nOptionally, you can even detect registrations from custom properties:\n\n```pcss\n:root {\n  --some-border: 5px solid rebeccapurple;\n  --some-image: url(\"image.webp\");\n  --some-transform: scale(1.25, 1.25);\n}\n```\n\n```json\n[\n  {\n    \"name\": \"--some-border\",\n    \"syntax\": \"\u003clength\u003e \u003ccustom-ident\u003e \u003ccolor\u003e\"\n  },\n  {\n    \"name\": \"--some-image\",\n    \"syntax\": \"\u003cimage\u003e\"\n  },\n  {\n    \"name\": \"--some-transform\",\n    \"syntax\": \"\u003ctransform-function\u003e\"\n  }\n]\n```\n\n## Usage\n\nAdd [PostCSS Register Property] to your project:\n\n```bash\nnpm install postcss-register-property --save-dev\n```\n\nUse [PostCSS Register Property] to process your CSS:\n\n```js\nconst postcssRegisterProperty = require('postcss-register-property');\n\npostcssRegisterProperty.process(YOUR_CSS /*, processOptions, pluginOptions */);\n```\n\nOr use it as a [PostCSS] plugin:\n\n```js\nconst postcss = require('postcss');\nconst postcssRegisterProperty = require('postcss-register-property');\n\npostcss([\n  postcssRegisterProperty(/* pluginOptions */)\n]).process(YOUR_CSS /*, processOptions */);\n```\n\n[PostCSS Register Property] runs in all Node environments, with special instructions for:\n\n| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |\n| --- | --- | --- | --- | --- | --- |\n\n## Options\n\n### detect\n\nThe `detect` option determines whether registrations will be detected from\nCustom Properties. By default, they are not detected.\n\n```js\npostcssRegisterProperty({ detect: true }) // detect custom property registrations\n```\n\n### getJSON\n\nThe `getJSON` option defines the function that handles all of the collected\nproperties from CSS. If not specified, these properties will be written as JSON\nto a file determined by the `to` option.\n\nIf specified, the `getJSON` function is passed 3 arguments; the path to the\nsource CSS, an object of all the collected properties, and the path to the\ndestination JSON. Asynchronous functions should return promise-like values.\n\n```js\npostcssRegisterProperty({\n  getJSON(cssFileName, properties, jsonFileName) {\n    /* do something with cssFileName, properties, and jsonFileName */\n  }\n)\n```\n\n### to\n\nThe `to` option determines the destination path where the properties will be\nwritten to as JSON. If not specified, the destination will be the input source\nfilename appended with `.properties.json`.\n\n[cli-img]: https://img.shields.io/travis/jonathantneal/postcss-register-property.svg\n[cli-url]: https://travis-ci.org/jonathantneal/postcss-register-property\n[git-img]: https://img.shields.io/badge/support-chat-blue.svg\n[git-url]: https://gitter.im/postcss/postcss\n[npm-img]: https://img.shields.io/npm/v/postcss-register-property.svg\n[npm-url]: https://www.npmjs.com/package/postcss-register-property\n\n[PostCSS]: https://github.com/postcss/postcss\n[PostCSS Register Property]: https://github.com/jonathantneal/postcss-register-property\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsstools%2Fpostcss-register-property","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsstools%2Fpostcss-register-property","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsstools%2Fpostcss-register-property/lists"}