{"id":20438192,"url":"https://github.com/kiprasmel/react-selectable-items","last_synced_at":"2026-04-21T04:03:37.656Z","repository":{"id":97544588,"uuid":"496314379","full_name":"kiprasmel/react-selectable-items","owner":"kiprasmel","description":"render a row of selectable items","archived":false,"fork":false,"pushed_at":"2022-05-31T12:26:50.000Z","size":67,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-20T13:26:04.215Z","etag":null,"topics":["component","items","react","selectable"],"latest_commit_sha":null,"homepage":"http://npm.im/react-selectable-items","language":"TypeScript","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/kiprasmel.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2022-05-25T16:44:19.000Z","updated_at":"2024-02-28T15:30:36.000Z","dependencies_parsed_at":"2023-03-13T16:11:22.943Z","dependency_job_id":null,"html_url":"https://github.com/kiprasmel/react-selectable-items","commit_stats":{"total_commits":31,"total_committers":1,"mean_commits":31.0,"dds":0.0,"last_synced_commit":"5986135d9de731d426f47d6baa0fb81cad3c1ba7"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/kiprasmel/react-selectable-items","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiprasmel%2Freact-selectable-items","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiprasmel%2Freact-selectable-items/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiprasmel%2Freact-selectable-items/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiprasmel%2Freact-selectable-items/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kiprasmel","download_url":"https://codeload.github.com/kiprasmel/react-selectable-items/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiprasmel%2Freact-selectable-items/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32076295,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T02:38:07.213Z","status":"ssl_error","status_checked_at":"2026-04-21T02:38:06.559Z","response_time":128,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","items","react","selectable"],"created_at":"2024-11-15T09:09:43.617Z","updated_at":"2026-04-21T04:03:37.622Z","avatar_url":"https://github.com/kiprasmel.png","language":"TypeScript","readme":"# react-selectable-items\n\nrender a row of selectable items\n\n## example\n\ncreate a feedback rating component with stars as the items\n\n```ts\nimport { SelectableItems, Unselected } from 'react-selectable-items'\n\ntype FeedbackRating = Unselected | 1 | 2 | 3 | 4 | 5\n\nexport function Stars() {\n\tconst [starsSelectedUpUntil, setStarsSelectedUpUntil] = useState\u003cFeedbackRating\u003e(0)\n\t\n\tconsole.log({ starsSelectedUpUntil })\n\n\treturn \u003cSelectableItems\u003cFeedbackRating\u003e\n\t\tcount={5}\n\t\t\n\t\tItemEmpty={StarEmpty}\n\t\tItemSelected={StarFilled}\n\t\t\n\t\tselectedUpUntil={starsSelectedUpUntil}\n\t\tsetSelectedUpUntil={setStarsSelectedUpUntil}\n\t\t\n\t\tselectionStrategy=\"all-before-and-current\"\n\t\tselectionDirection=\"left-to-right\"\n\t/\u003e\n}\n\t\nfunction StarEmpty() {\n\treturn \u003cspan\u003e⭐\u003c/span\u003e\n}\n\nfunction StarFilled() {\n\treturn \u003cspan\u003e🌠\u003c/span\u003e\n}\n\n```\n\n### styling\n\nthough, we've never actually used this ourselves\n\n```css\n.selectable-items__initial-wrapper { }\n\n.selectable-items__item { }\n\n.selectable-items__item--selected { }\n.selectable-items__item--not-selected { }\n\n.selectable-items__item--first { }\n.selectable-items__item--last { }\n\n```\n\n## example with an error state\n\nyou can do all the same, but additionally provide a `Wrapper` prop,\nthus overriding our default \u0026 very minimal wrapper,\nand in your Wrapper you can e.g. show a red border if the field was required but wasn't selected.\n\n```ts\nimport styled from '@emotion/styled';\n\nexport function Stars() {\n\tconst [starsSelectedUpUntil, setStarsSelectedUpUntil] = useState\u003cFeedbackRating\u003e(0)\n\tconst [hasError, setHasError] = useState\u003cboolean\u003e(false)\n\n\treturn \u003cSelectableItems\u003cFeedbackRating\u003e\n\t\tcount={5}\n\t\t\n\t\tItemEmpty={StarEmpty}\n\t\tItemSelected={StarFilled}\n\t\t\n\t\tselectedUpUntil={starsSelectedUpUntil}\n\t\tsetSelectedUpUntil={setStarsSelectedUpUntil}\n\t\t\n\t\tselectionStrategy=\"all-before-and-current\"\n\t\tselectionDirection=\"left-to-right\"\n\n\t\tWrapper={({ children }) =\u003e (\n\t\t\t\u003cErrorBorderWrapper hasError={!!hasError}\u003e\n\t\t\t\t{children}\n\t\t\t\u003c/ErrorBorderWrapper\u003e\n\t\t)}\n\t/\u003e\n}\n\nconst ErrorBorderWrapper = styled.div\u003c{ hasError: boolean }\u003e`\n\tdisplay: inline-block;\n\n\t${({ hasError }) =\u003e\n\t\t!hasError\n\t\t\t? ``\n\t\t\t: `\n\t\tborder: 1px solid red;\n\t\tborder-radius: 4px;\n\t`}\n`;\n\n```\n\n## License\n\n[MIT](./LICENSE) (c) 2022 Kipras Melnikovas\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiprasmel%2Freact-selectable-items","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkiprasmel%2Freact-selectable-items","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiprasmel%2Freact-selectable-items/lists"}