{"id":16226282,"url":"https://github.com/ghostdevv/svelte-body","last_synced_at":"2025-03-16T12:31:50.991Z","repository":{"id":37930707,"uuid":"404143618","full_name":"ghostdevv/svelte-body","owner":"ghostdevv","description":"Apply styles to the body in routes! Designed to work with Svelte Kit and Routify","archived":false,"fork":false,"pushed_at":"2023-10-07T22:14:05.000Z","size":362,"stargazers_count":64,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-26T00:42:33.934Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ghostdevv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"patreon":"onlyspaceghost","custom":"https://ghostdev.xyz/donate"}},"created_at":"2021-09-07T22:52:28.000Z","updated_at":"2024-06-19T05:15:31.696Z","dependencies_parsed_at":"2024-06-19T05:15:22.051Z","dependency_job_id":"2c04a391-70e1-4433-8b9a-c091ad924050","html_url":"https://github.com/ghostdevv/svelte-body","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostdevv%2Fsvelte-body","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostdevv%2Fsvelte-body/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostdevv%2Fsvelte-body/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostdevv%2Fsvelte-body/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghostdevv","download_url":"https://codeload.github.com/ghostdevv/svelte-body/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814880,"owners_count":20352037,"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":["hacktoberfest"],"created_at":"2024-10-10T12:48:38.830Z","updated_at":"2025-03-16T12:31:50.695Z","avatar_url":"https://github.com/ghostdevv.png","language":"TypeScript","readme":"# Svelte Body\n\nCurrently in Svelte Kit and Routify, applying styles per page to the body doesn't work. You can't use `:global(body)` since the style tags aren't removed and reapplied on route change. `svelte-body` handles that for you. It's available as an action or component.\n\n# Install\n\n```bash\nnpm i svelte-body -D\n```\n\nThis library is made for Svelte 5, if you'd like to use Svelte 3/4 [checkout v1](https://www.npmjs.com/package/svelte-body/v/1.4.0).\n\n# Usage\n\nJust like in regular html you can apply classes with `class=\"\"` and styles with `style=\"\"`.\n\n```svelte\n\u003cscript\u003e\n\timport { Body } from 'svelte-body';\n\u003c/script\u003e\n\n\u003cBody class=\"some classes\" style=\"color: blue\" /\u003e\n```\n\nAlternativley you can use a style object like so:\n\n```svelte\n\u003cscript\u003e\n\timport { Body } from 'svelte-body';\n\n\tconst style = {\n\t\tbackgroundColor: 'violet',\n\t\tcolor: 'white',\n\t\t'--cool-css-prop': '😎',\n\t};\n\u003c/script\u003e\n\n\u003cBody {style} /\u003e\n```\n\nWe use [clsx](https://github.com/lukeed/clsx) under the hood, which allows you to pass different shapes and only have truthy names applied as classes. Read me about it on their docs.\n\n```svelte\n\u003cscript\u003e\n\timport { classList } from 'svelte-body';\n\n\tlet isBlue = $state(true);\n\u003c/script\u003e\n\n\u003cBody class=\"red green blue\" /\u003e\n\u003cBody class={{ red: true, blue: isBlue }} /\u003e\n\u003cBody class={['red', isBlue \u0026\u0026 'blue']} /\u003e\n\u003cBody class={['red', { blue: isBlue }]} /\u003e\n```\n\n## Actions\n\nWe also provide a `classList` and `style` action, which can be used on `\u003csvelte:body /\u003e` (or any other element).\n\n-   `classList`\n\n    ```svelte\n    \u003cscript\u003e\n        import { classList } from 'svelte-body';\n    \u003c/script\u003e\n\n    \u003csvelte:body use:classList={\"red green blue\"} /\u003e\n    \u003csvelte:body use:classList={{ red: true, blue: isBlue }} /\u003e\n    \u003csvelte:body use:classList={['red', isBlue \u0026\u0026 'blue']} /\u003e\n    \u003csvelte:body use:classList={[ 'red', { blue: isBlue } ]} /\u003e\n    ```\n\n-   `style`\n\n    ```svelte\n    \u003cscript\u003e\n    \timport { style } from 'svelte-body';\n    \u003c/script\u003e\n\n    \u003csvelte:body use:style={'background-color: blue;'} /\u003e\n    ```\n\n    It can also take an object:\n\n    ```svelte\n    \u003cscript\u003e\n    \timport { style } from 'svelte-body';\n    \u003c/script\u003e\n\n    \u003csvelte:body\n    \tuse:style={{ backgroundColor: 'blue', '--cool-css-prop': '😎' }} /\u003e\n    ```\n\n# Migrating from v1 to v2\n\n-   Svelte 5 is now required\n-   We updated to [clsx v2](https://github.com/lukeed/clsx/releases/tag/v2.0.0)\n\n[Read the full changelog](https://github.com/ghostdevv/svelte-body/releases/tag/v2.0.0).\n\n# Support\n\n-   Join the [discord](https://discord.gg/2Vd4wAjJnm)\u003cbr\u003e\n-   Create a issue on the [github](https://github.com/ghostdevv/svelte-body)\n","funding_links":["https://patreon.com/onlyspaceghost","https://ghostdev.xyz/donate"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostdevv%2Fsvelte-body","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghostdevv%2Fsvelte-body","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostdevv%2Fsvelte-body/lists"}