{"id":13755491,"url":"https://github.com/trendmicro-frontend/react-radio","last_synced_at":"2025-07-22T08:33:04.696Z","repository":{"id":57167651,"uuid":"90846339","full_name":"trendmicro-frontend/react-radio","owner":"trendmicro-frontend","description":"React Radio component","archived":false,"fork":false,"pushed_at":"2023-09-22T14:10:55.000Z","size":3798,"stargazers_count":11,"open_issues_count":3,"forks_count":3,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-07-08T09:11:31.328Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://trendmicro-frontend.github.io/react-radio","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/trendmicro-frontend.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}},"created_at":"2017-05-10T09:28:26.000Z","updated_at":"2023-09-22T14:11:00.000Z","dependencies_parsed_at":"2024-01-17T15:04:24.601Z","dependency_job_id":"840e765c-c83d-46dc-9f57-042e55198787","html_url":"https://github.com/trendmicro-frontend/react-radio","commit_stats":null,"previous_names":["trendmicro-frontend/react-radio-button"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/trendmicro-frontend/react-radio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trendmicro-frontend%2Freact-radio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trendmicro-frontend%2Freact-radio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trendmicro-frontend%2Freact-radio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trendmicro-frontend%2Freact-radio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trendmicro-frontend","download_url":"https://codeload.github.com/trendmicro-frontend/react-radio/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trendmicro-frontend%2Freact-radio/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266456245,"owners_count":23931383,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-08-03T10:00:55.183Z","updated_at":"2025-07-22T08:33:04.672Z","avatar_url":"https://github.com/trendmicro-frontend.png","language":"JavaScript","funding_links":[],"categories":["Trend Micro"],"sub_categories":["React Components"],"readme":"# react-radio [![build status](https://travis-ci.org/trendmicro-frontend/react-radio.svg?branch=master)](https://travis-ci.org/trendmicro-frontend/react-radio) [![Coverage Status](https://coveralls.io/repos/github/trendmicro-frontend/react-radio/badge.svg?branch=master)](https://coveralls.io/github/trendmicro-frontend/react-radio?branch=master)\n\n[![NPM](https://nodei.co/npm/@trendmicro/react-radio.png?downloads=true\u0026stars=true)](https://nodei.co/npm/@trendmicro/react-radio/)\n\nReact Radio\n\nDemo: https://trendmicro-frontend.github.io/react-radio\n\n## Installation\n\n1. Install the latest version of [react](https://github.com/facebook/react) and [react-radio](https://github.com/trendmicro-frontend/react-radio):\n\n  ```\n  npm install --save react @trendmicro/react-radio\n  ```\n\n2. At this point you can import `@trendmicro/react-radio` and its styles in your application as follows:\n\n  ```js\n  import { RadioButton, RadioGroup } from '@trendmicro/react-radio';\n\n  // Be sure to include styles at some point, probably during your bootstraping\n  import '@trendmicro/react-radio/dist/react-radio.css';\n  ```\n\n## Usage\n\n### RadioButton\n\n```jsx\n\u003cRadioButton\u003eRadioButton label\u003c/RadioButton\u003e\n```\n\nYou can use children to pass through the component.\n\n```jsx\n\u003cRadioButton\u003e\n    \u003cspan style={{ verticalAlign: 'middle', marginLeft: 8 }}\u003e\n        Lorem ipsum dolor sit amet...\n    \u003c/span\u003e\n\u003c/RadioButton\u003e\n```\n\nOr pass tag to customize the wrapper component.\n```jsx\n\u003cRadioButton tag='span'\u003e\n    Lorem ipsum dolor sit amet...\n\u003c/RadioButton\u003e\n```\n\n\n#### Uncontrolled RadioButton\n\n```js\n// Default checked\n\u003cRadioButton defaultChecked /\u003e\n```\n\n#### Controlled RadioButton\n\n```js\n// Checked\n\u003cRadioButton checked /\u003e\n```\n\n### RadioGroup\n\n```jsx\n\u003cRadioGroup\n    name=\"comic\"\n    value={this.state.value}\n    onChange={(event) =\u003e {\n        const value = event.target.value;\n        this.setState({ value: value });\n    }}\n\u003e\n    \u003cdiv className=\"row\"\u003e\n        \u003cdiv className=\"col-xs-12 col-sm-6\"\u003e\n            \u003cRadioButton value=\"dc:batman\"\u003eBatman (DC)\u003c/RadioButton\u003e\n            \u003cRadioButton value=\"marvel:hulk\"\u003eHulk (Marvel)\u003c/RadioButton\u003e\n        \u003c/div\u003e\n        \u003cdiv className=\"col-xs-12 col-sm-6\"\u003e\n            \u003cRadioButton value=\"dc:superman\"\u003eSuperman (DC)\u003c/RadioButton\u003e\n            \u003cRadioButton value=\"marvel:spiderman\" disabled\u003eSpider-Man (Marvel)\u003c/RadioButton\u003e\n        \u003c/div\u003e\n    \u003c/div\u003e\n\u003c/RadioGroup\u003e\n```\n\n## Prevent onChange Propagation\n\nYou may need to use `event.stopPropagation()` to stop **onChange** propagation when wrapping an input element inside the **RadioGroup** or **RadioButton** component.\n\n```jsx\n\u003cRadioGroup\n    name=\"radiogroup\"\n    value={this.state.value}\n    onChange={(event) =\u003e {\n        const value = event.target.value;\n        this.setState({ value: value });\n    }}\n\u003e\n    \u003cRadioButton value=\"one\"\u003e\n        \u003cspan\u003eFirst option\u003c/span\u003e\n        \u003cdiv style={{ marginLeft: 22 }}\u003e\n            \u003cinput\n                type=\"text\"\n                onChange={(event) =\u003e {\n                    // Prevent onChange propagation\n                    event.stopPropagation();\n                }}\n            /\u003e\n        \u003c/div\u003e\n    \u003c/RadioButton\u003e\n    \u003cRadioButton value=\"two\"\u003e\n        \u003cspan\u003eSecond option\u003c/span\u003e\n        \u003cdiv style={{ marginLeft: 22 }}\u003e\n            \u003cinput\n                type=\"text\"\n                onChange={(event) =\u003e {\n                    // Prevent onChange propagation\n                    event.stopPropagation();\n                }}\n            /\u003e\n        \u003c/div\u003e\n    \u003c/RadioButton\u003e\n\u003c/RadioGroup\u003e\n```\n\n## API\n\n### Properties\n\n#### RadioButton\n\nName | Type | Default | Description\n:--- | :--- | :------ | :----------\nchildren | any | | Children to pass through the component.\nclassName | Object | | Customized class name for the component.\nstyle | Object | | Customized style for the component.\nchecked | Boolean | | If true, the radio button will be selected. Transferred from the radio group.\ndefaultChecked | Boolean | | The default checked state of the radio button.\ndisabled | Boolean | false | If true, the radio button will be shown as disabled and cannot be modified.\ntag | Function or String | label | Customized wrapper component to replace label.\nid | String | | Id for the input field of radio button.\nname | String | | Name for the input element.\nvalue | any | | Value for the radio button.\nonChange | Function | | Callback function that will be invoked when the value changes.\n\n#### RadioGroup\n\nName | Type | Default | Description\n:--- | :--- | :------ | :----------\nchildren | any | | Children to pass through the component.\ndisabled | Boolean | false | If true, the radio group will be displayed as disabled.\nname | String | | Name for the input element group.\nvalue | any | | The value of the radio group.\ndefaultValue | any | | The default value of the radio group.\nonChange | Function | | Callback function that will be invoked when the value changes.\n\n### Class Properties\n\n#### RadioButton\n\nUse the ref property to get a reference to radio button:\n\n```jsx\nconst ref = React.createRef();\n\u003cRadioButton ref={ref} /\u003e\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrendmicro-frontend%2Freact-radio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrendmicro-frontend%2Freact-radio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrendmicro-frontend%2Freact-radio/lists"}