{"id":13726023,"url":"https://github.com/developit/preact-slots","last_synced_at":"2025-06-11T05:07:13.219Z","repository":{"id":57329563,"uuid":"119446624","full_name":"developit/preact-slots","owner":"developit","description":"🕳 Render Preact trees into other Preact trees, like portals.","archived":false,"fork":false,"pushed_at":"2020-05-19T01:41:40.000Z","size":64,"stargazers_count":156,"open_issues_count":7,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-03T21:40:51.256Z","etag":null,"topics":["preact","preact-components"],"latest_commit_sha":null,"homepage":"https://npm.im/preact-slots","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/developit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-29T21:52:06.000Z","updated_at":"2025-03-30T17:23:57.000Z","dependencies_parsed_at":"2022-09-14T19:01:56.770Z","dependency_job_id":null,"html_url":"https://github.com/developit/preact-slots","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fpreact-slots","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fpreact-slots/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fpreact-slots/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fpreact-slots/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/developit","download_url":"https://codeload.github.com/developit/preact-slots/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developit%2Fpreact-slots/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":258868836,"owners_count":22770423,"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":["preact","preact-components"],"created_at":"2024-08-03T01:02:48.196Z","updated_at":"2025-06-11T05:07:13.196Z","avatar_url":"https://github.com/developit.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n    \u003cimg align=\"center\" src=\"https://i.imgur.com/8b1gCrF.jpg\" width=\"1650\"\u003e\n\u003c/div\u003e\n\n# preact-slots [![npm](https://img.shields.io/npm/v/preact-slots.svg?style=flat)](https://www.npmjs.org/package/preact-slots) [![travis](https://travis-ci.org/developit/preact-slots.svg?branch=master)](https://travis-ci.org/developit/preact-slots)\n\nRender Preact trees into other Preact trees, like portals.\n\n\n## Install\n\n**preact-slots** is available on npm:\n\n`npm install --save preact-slots`\n\n\n### Usage\n\nDefine \"holes\" in your appliation using `\u003cSlot name=\"foo\" /\u003e`,\nthen fill them using `\u003cSlotContent slot=\"foo\"\u003esome content\u003c/SlotContent\u003e`:\n\n```js\nimport { SlotProvider, Slot, SlotContent } from 'preact-slots'\n\nrender(\n    \u003cSlotProvider\u003e\n        \u003cdiv\u003e\n            \u003cSlot name=\"foo\"\u003e\n                Some Fallback Content\n            \u003c/Slot\u003e\n            \u003cSlotContent slot=\"foo\"\u003e\n                Replacement Content\n            \u003c/SlotContent\u003e\n        \u003c/div\u003e\n    \u003c/SlotProvider\u003e\n)\n```\n\nThe above renders `\u003cdiv\u003eReplacement Content\u003c/div\u003e`.\n\nAn extended example follows:\n\n```js\nimport { Slot, SlotContent, SlotProvider } from 'preact-slots'\n\nconst Header = () =\u003e (\n    \u003cheader class=\"header\"\u003e\n        \u003cSlot name=\"title\"\u003eSlots Demo\u003c/Slot\u003e\n        \u003cSlot name=\"toolbar\"\u003e\n            { items =\u003e items \u0026\u0026 \u003cnav\u003e{items}\u003c/nav\u003e }\n        \u003c/Slot\u003e\n    \u003c/header\u003e\n)\n\nconst EditPage = ({ page, content, onSave, onCancel }) =\u003e (\n    \u003cdiv class=\"page-editor\"\u003e\n        \u003cSlotContent slot=\"title\"\u003eEditing {page}\u003c/SlotContent\u003e\n        \u003cSlotContent slot=\"toolbar\"\u003e\n            \u003cbutton onClick={onSave}\u003eSave\u003c/button\u003e\n            \u003cbutton onClick={onCancel}\u003eCancel\u003c/button\u003e\n        \u003c/SlotContent\u003e\n        \u003ctextarea value={content} /\u003e\n    \u003c/div\u003e\n)\n\nrender(\n    \u003cSlotProvider\u003e\n        \u003cdiv class=\"app\"\u003e\n            \u003cHeader /\u003e\n            \u003cEditPage /\u003e\n        \u003c/div\u003e\n    \u003c/SlotProvider\u003e\n)\n```\n\n\n### Similar Libraries\n\nSlots are a concept that has been around for a while.\n\nIn particular, [@camwest](https://github.com/camwest)'s [react-slot-fill](https://github.com/camwest/react-slot-fill) is similar to preact-slots, but geared towards React.\n\n\n### License\n\n[MIT License](https://oss.ninja/mit/developit) © [Jason Miller](https://jasonformat.com)\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopit%2Fpreact-slots","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevelopit%2Fpreact-slots","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevelopit%2Fpreact-slots/lists"}