{"id":14970975,"url":"https://github.com/rubenvar/svelte-star-rating","last_synced_at":"2025-10-26T14:30:35.521Z","repository":{"id":43040880,"uuid":"270752468","full_name":"rubenvar/svelte-star-rating","owner":"rubenvar","description":"A simple svelte component that shows a star rating from 0 to 5","archived":false,"fork":false,"pushed_at":"2023-06-06T02:28:51.000Z","size":276,"stargazers_count":7,"open_issues_count":4,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-09-28T13:42:39.034Z","etag":null,"topics":["component","no-dependencies","props","rating-number","sapper","star-rating","svelte","svelte-kit","sveltejs","sveltekit"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/svelte-star-rating","language":"Svelte","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/rubenvar.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-08T17:02:27.000Z","updated_at":"2023-03-06T14:02:57.000Z","dependencies_parsed_at":"2024-06-21T16:35:15.979Z","dependency_job_id":"ede5b9ef-e4d6-432a-b533-8f51f2e2f718","html_url":"https://github.com/rubenvar/svelte-star-rating","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenvar%2Fsvelte-star-rating","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenvar%2Fsvelte-star-rating/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenvar%2Fsvelte-star-rating/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenvar%2Fsvelte-star-rating/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubenvar","download_url":"https://codeload.github.com/rubenvar/svelte-star-rating/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219862755,"owners_count":16555951,"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":["component","no-dependencies","props","rating-number","sapper","star-rating","svelte","svelte-kit","sveltejs","sveltekit"],"created_at":"2024-09-24T13:44:26.861Z","updated_at":"2025-10-26T14:30:35.161Z","avatar_url":"https://github.com/rubenvar.png","language":"Svelte","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Svelte Star Rating\n\n## What is this\n\nA simple [svelte](https://svelte.dev/) component that shows a rating from 0 to 5 with svg stars. Just need to pass a number. No dependencies required.\n\n## Installation\n\nAs with any other node package in svelte:\n\n```bash\nnpm install svelte-star-rating\n```\n\nBut remember to install it as a **dev dependency** when using it with [SvelteKit](https://kit.svelte.dev/) (or [Sapper](https://sapper.svelte.dev/)):\n\n```bash\nnpm install svelte-star-rating --save-dev\n```\n\n## Usage\n\nThe package exports a svelte component.\n\nThe component takes a number of props:\n\n| Prop   | Type   | Default | Required | Description                                           |\n| ------ | ------ | ------- | -------- | ----------------------------------------------------- |\n| rating | Number | -       | Yes      | The rating. Any number from 0 to 5.0                  |\n| config | Object | {}      | No       | Config options for the component. See below           |\n| style  | String | -       | No       | CSS styles passed directly to the container component |\n\n**About the config object**:\n\n| Option     | Type    | Default   | Description                                     |\n| ---------- | ------- | --------- | ----------------------------------------------- |\n| emptyColor | String  | '#7f7f7f' | The color for the empty parts of the stars      |\n| fullColor  | String  | '#ffcf00' | The color for the filling of the stars          |\n| showText   | Boolean | false     | Show the rating number next to the stars or not |\n| size       | Number  | 20        | The size of the stars. Pass a number of pixels. |\n\n**About the style prop**: It accepts a string of css styles, written as inline-css. It is passed directly, unchecked, to the main `div` as inline-css. Use it cautiously.\n\n## Be aware\n\n- Passing a rating higher than 5.0 or lower than 0.0 will throw an error.\n- The component is reactive since v1.3.0 (if rating value changes, the component will change the displayed rating).\n- Any css-valid color is accepted (hsl, hex, rgb, string, etc.).\n- Stars are 1:1 proportionate (width equals height, so both equal the size property).\n- If the rating number text is shown (`showText: true`), font size is half the star size or 16px, whatever is higher.\n\nAlso:\n\n- The component doesn't handle in any way the number passed as rating: If you operate on the number, you may end up with a value of `3.02 + 0.01 = 3.0299999995`, for example, due to *the way JavaScript works*. It's up to you to manage this before passing the number.\n\n## Example\n\nUse it as follows:\n\n### Simple\n\n```svelte\n\u003cscript\u003e\n  import StarRating from 'svelte-star-rating';\n\u003c/script\u003e\n\n\u003cStarRating rating={3.35} /\u003e\n```\n\nOutput:\n\n![Simple example of Svelte Star Rating](./docs/example-simple.jpg)\n\n### Advanced\n\n```svelte\n\u003cscript\u003e\n  import StarRating from 'svelte-star-rating';\n  \n  const rating = 3.35;\n  const config = {\n    emptyColor: 'hsl(240, 80%, 85%)',\n    fullColor: '#f05',\n    showText: true,\n    size: 42,\n  };\n  const style = 'border: 1px solid firebrick;padding: 12px;';\n\u003c/script\u003e\n\n\u003cStarRating {rating} {config} {style} /\u003e\n```\n\nOutput:\n\n![Advanced example of Svelte Star Rating](./docs/example-advanced.jpg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubenvar%2Fsvelte-star-rating","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubenvar%2Fsvelte-star-rating","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubenvar%2Fsvelte-star-rating/lists"}