{"id":13481329,"url":"https://github.com/jxom/react-selected","last_synced_at":"2025-05-05T04:14:32.191Z","repository":{"id":57344420,"uuid":"136447396","full_name":"jxom/react-selected","owner":"jxom","description":"React component to build flexible and accessible radio buttons/elements.","archived":false,"fork":false,"pushed_at":"2019-10-18T00:37:28.000Z","size":481,"stargazers_count":25,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-05T04:14:23.071Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://jxom.github.io/react-selected/","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/jxom.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}},"created_at":"2018-06-07T08:35:00.000Z","updated_at":"2024-08-19T11:28:57.000Z","dependencies_parsed_at":"2022-09-11T08:41:55.120Z","dependency_job_id":null,"html_url":"https://github.com/jxom/react-selected","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/jxom%2Freact-selected","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jxom%2Freact-selected/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jxom%2Freact-selected/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jxom%2Freact-selected/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jxom","download_url":"https://codeload.github.com/jxom/react-selected/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252436586,"owners_count":21747472,"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":[],"created_at":"2024-07-31T17:00:50.907Z","updated_at":"2025-05-05T04:14:32.172Z","avatar_url":"https://github.com/jxom.png","language":"JavaScript","funding_links":[],"categories":["Components","Libraries"],"sub_categories":["Inputs"],"readme":"# React Selected\n\n\u003e React component to build flexible and accessible radio buttons/elements. \n\nListen to [Belinda Carlisle - Summer Rain](https://www.youtube.com/watch?v=wssIZOBV9i4) while reading these docs - it will increase comprehensibility by 120%. [This](https://youtu.be/R_TcZ-ATihY?t=5m10s) will increase it by 420%.\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"./react-selected.png\" width=\"400px\"\u003e\u003c/img\u003e\u003c/p\u003e\n\n## Why should I use this?\n\nReact Selected has control over select logic and state meaning that you don't have to do much! It also has the ability to add WAI-ARIA compliant and other accessibility attributes to the selectable elements.\n\n## Install\n\n`npm install react-selected`\n\n## Example\n\n```jsx\nimport Selected from 'react-selected';\n\n\u003cSelected defaultSelectedKey=\"cat\"\u003e\n  {({ getSelectableProps, selectedKey }) =\u003e (\n    \u003cButtons\u003e\n      \u003cButton color={selectedKey === 'dog' ? 'info' : null} {...getSelectableProps('dog')}\u003e\n        Dog\n      \u003c/Button\u003e\n      \u003cButton color={selectedKey === 'cat' ? 'info' : null} {...getSelectableProps('cat')}\u003e\n        Cat\n      \u003c/Button\u003e\n      \u003cButton color={selectedKey === 'mouse' ? 'info' : null} {...getSelectableProps('mouse')}\u003e\n        Mouse\n      \u003c/Button\u003e\n    \u003c/Buttons\u003e\n  )}\n\u003c/Selected\u003e\n```\n\n### More examples\n\n- [Storybook](https://jxom.github.io/react-selected/)\n- [Storybook Stories](https://github.com/jxom/react-selected/blob/master/src/__stories__/index.stories.js)\n\n## Props\n\n### defaultSelectedKey\n\nType: `string`\n\nThe key of the component that should be selected by default.\n\n### onSelect\n\nType: `function({ key, value })`\n\nFunction to invoke when a component is selected.\n\n### selectedKey\n\nType: `string`\n\nReact Selected manages select logic and state internally, but if you wish to have your own, you can control the value of `selectedKey`.\n\n### Render props\n\n#### getSelectableProps\n\nType: `function(key, value, props)` **(`key` is required)**\n\nReturns the props to apply to the button element you render. \nIncludes `aria-` attributes.\n\n#### getElementSelectableProps\n\nType: `function(key, value, props)` **(`key` is required)**\n\nReturns the props to apply to the element you render. Use this for any element other than a \u003ccode\u003e\u0026lt;button\u0026gt;\u003c/code\u003e. \nIncludes \u003ccode\u003earia-\u003c/code\u003e attributes.\n\n#### select\n\nType: `function(key, value)`\n\nSets `selectedKey` to `key` and sets `selectedValue` to `value`.\n\n#### selectedKey\n\nType: `string`\n\nThe key of the current selected component.\n\n#### selectedValue\n\nType: `string`\n\nThe value of the current selected component.\n\n## Inspiration\n\n- [Downshift](https://github.com/paypal/downshift)\n- [React Toggled](https://github.com/kentcdodds/react-toggled)\n\n## License\n\nMIT © [jxom](http://jxom.io)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjxom%2Freact-selected","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjxom%2Freact-selected","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjxom%2Freact-selected/lists"}