{"id":20730374,"url":"https://github.com/philipbordallo/postcss-stack","last_synced_at":"2025-04-23T21:51:46.738Z","repository":{"id":47248302,"uuid":"138683162","full_name":"philipbordallo/postcss-stack","owner":"philipbordallo","description":"A better way to manage z-indexes","archived":false,"fork":false,"pushed_at":"2021-09-07T02:35:28.000Z","size":494,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T03:51:11.695Z","etag":null,"topics":["css","postcss","z-index"],"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/philipbordallo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-26T04:07:10.000Z","updated_at":"2022-05-25T17:50:08.000Z","dependencies_parsed_at":"2022-07-20T20:03:18.350Z","dependency_job_id":null,"html_url":"https://github.com/philipbordallo/postcss-stack","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipbordallo%2Fpostcss-stack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipbordallo%2Fpostcss-stack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipbordallo%2Fpostcss-stack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipbordallo%2Fpostcss-stack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philipbordallo","download_url":"https://codeload.github.com/philipbordallo/postcss-stack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250042893,"owners_count":21365515,"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","postcss","z-index"],"created_at":"2024-11-17T05:11:22.695Z","updated_at":"2025-04-23T21:51:46.717Z","avatar_url":"https://github.com/philipbordallo.png","language":"JavaScript","readme":"# PostCSS Stack [\u003cimg src=\"https://postcss.github.io/postcss/logo.svg\" alt=\"PostCSS\" width=\"90\" height=\"90\" align=\"right\"\u003e][postcss]\n\u003e A better way to manage z-indexes\n\n[![NPM Version][npm-img]][npm-url]\n[![Build Status][ci-img]][ci-url]\n[![Dependency Status][david-img]][david-url] \n\nDefine the stack of components and PostCSS Stack will resolve the z-indexes for you instead of playing a game of `z-index: 99999`.\n\n```css\n/* input */\n.modal {\n  z-index: stack('modal');\n}\n\n.tool-tip {\n  z-index: stack('tool-tip');\n}\n\n.element-beneath {\n  z-index: stack('beneath');\n}\n```\n\n\n```css\n/* output */\n.modal {\n  z-index: 2;\n}\n\n.tool-tip {\n  z-index: 1;\n}\n\n.element-beneath {\n  z-index: -1;\n}\n```\n\n\n## Install ##\n\n```sh\n# npm\nnpm install --save-dev postcss postcss-stack\n\n# or yarn\nyarn add --dev postcss postcss-stack\n```\n\n\n## Usage ##\n\nAdd it to your PostCSS work-flow, [whatever way you choose to](https://github.com/postcss/postcss#usage).\n\n```js\n// Using a postcss.config.js\nconst stack = require('postcss-stack');\n\nmodule.exports = {\n  plugins: [\n    stack({\n      list: [\n        { 'beneath': -1 },\n        'application',\n        'tool-tip',\n        'modal'\n      ]\n    })\n  ]\n};\n```\n\nThen call the `stack` function with relevant item name in your css.\n\n```css\n/* input */\n.application {\n  z-index: stack('application');\n}\n```\n\n```css\n/* output */\n.application {\n  z-index: 0;\n}\n```\n\nSee [tests](./tests/) for more examples.\n\n## Options ##\n\noption | type | default | description\n:--- |:--- |:--- |:--- \n[**`list`**](#list) | _array_ or _function_ | `[]` |  Array of items in the stack or function returning array of items\n[**`increment`**](#increment) | _number_ | `1` | The increment value \n\n### `list`\nThe list of items that defines the stack. An item can either be explicitly defined by a name key and z-index value or by a name string that will have it's z-index auto-generated.\n\n```js\nstack({\n  list: [\n    { 'explicit': -10 }, // stack('explicit') =\u003e z-index: -10\n    'auto', // stack('auto') =\u003e z-index: 0\n    'generated', // stack('generated') =\u003e z-index: 1\n  ]\n});\n```\n\nBy default it's ordered by the order of the array, but you can use `Array.prototype.reverse()` to better visualize how the stack is set.\n\n\n```js\nstack({\n  list: [\n    { 'beneath': -1 }, // z-index: -1\n    'application', // z-index: 0\n    'tool-tip',  // z-index: 1\n    'modal'  // z-index: 2\n  ]\n});\n\n// Reversed\nstack({\n  list: [\n    'modal' // z-index: 2\n    'tool-tip', // z-index: 1\n    'application', // z-index: 0\n    { 'beneath': -1 }, // z-index: -1\n  ].reverse();\n});\n```\n\n\n### `increment`\n\nAllows a increment value to be set. For example if `increment: 100`, the output of our example would be:\n\n```css\n.modal {\n  z-index: 200;\n}\n\n.tool-tip {\n  z-index: 100;\n}\n\n.element-beneath {\n  z-index: -1;\n}\n```\n\n## Stacking Context ##\n\nRemember that stacking context is relative to the parent, so if you have a parent element that is `z-index: 2` and a child of `z-index: 1`, the child will not be below the parent but instead relative to any other stacking context of that parent. \n\nFor more information on stacking context, [MDN has a good overview](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context).\n\n\n## [License](./LICENSE) ##\n\n\n[david-img]: https://img.shields.io/david/philipbordallo/postcss-stack.svg\n[david-url]: https://david-dm.org/philipbordallo/postcss-stack\n\n[ci-img]: https://img.shields.io/github/workflow/status/philipbordallo/postcss-stack/Continuous%20Integration\n[ci-url]: https://github.com/philipbordallo/postcss-stack/actions/workflows/ci.yml\n\n[npm-img]: https://img.shields.io/npm/v/postcss-stack.svg\n[npm-url]: https://www.npmjs.com/package/postcss-stack\n\n[postcss]: https://github.com/postcss/postcss\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilipbordallo%2Fpostcss-stack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilipbordallo%2Fpostcss-stack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilipbordallo%2Fpostcss-stack/lists"}