{"id":21018958,"url":"https://github.com/reactabular/react-visibility-toggles","last_synced_at":"2025-05-15T06:31:57.363Z","repository":{"id":57141722,"uuid":"74894628","full_name":"reactabular/react-visibility-toggles","owner":"reactabular","description":"Visibility toggles for React (MIT)","archived":false,"fork":false,"pushed_at":"2017-10-02T14:48:27.000Z","size":425,"stargazers_count":2,"open_issues_count":2,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T05:13:17.728Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://reactabular.github.io/react-visibility-toggles/","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/reactabular.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-27T14:59:59.000Z","updated_at":"2018-05-30T04:50:53.000Z","dependencies_parsed_at":"2022-09-03T07:40:34.171Z","dependency_job_id":null,"html_url":"https://github.com/reactabular/react-visibility-toggles","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactabular%2Freact-visibility-toggles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactabular%2Freact-visibility-toggles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactabular%2Freact-visibility-toggles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactabular%2Freact-visibility-toggles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reactabular","download_url":"https://codeload.github.com/reactabular/react-visibility-toggles/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254288336,"owners_count":22045883,"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-11-19T10:28:20.282Z","updated_at":"2025-05-15T06:31:55.749Z","avatar_url":"https://github.com/reactabular.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![build status](https://secure.travis-ci.org/reactabular/react-visibility-toggles.svg)](http://travis-ci.org/reactabular/react-visibility-toggles) [![bitHound Score](https://www.bithound.io/github/reactabular/react-visibility-toggles/badges/score.svg)](https://www.bithound.io/github/reactabular/react-visibility-toggles) [![codecov](https://codecov.io/gh/reactabular/react-visibility-toggles/branch/master/graph/badge.svg)](https://codecov.io/gh/reactabular/react-visibility-toggles)\n\n# react-visibility-toggles - Visibility toggles for React\n\n`react-visibility-toggles` provides a React component for rendering visibility toggles for table columns. It works well with Reactabular.\n\n## Example\n\n```\n/*\nimport VisibilityToggles from 'react-visibility-toggles';\n*/\n\nconst columns = [\n  {\n    header: {\n      label: 'Name'\n    },\n    visible: true\n  },\n  {\n    header: {\n      label: 'Age'\n    },\n    visible: false\n  }\n];\n\n\u003cVisibilityToggles\n  columns={columns}\n  onToggleColumn={({ column, columnIndex }) =\u003e console.log(column, columnIndex)}\n  isVisible={({ column }) =\u003e column.visible}\n  props={{}}\n/\u003e\n```\n\n## Integrating with Reactabular\n\nThe following example shows how to integrate `react-visibility-toggles` with Reactabular:\n\n```jsx\n/*\nimport React from 'react';\nimport * as Table from 'reactabular-table';\nimport { cloneDeep } from 'lodash';\nimport VisibilityToggles from 'react-visibility-toggles';\n*/\n\nclass ToggleColumnsTable extends React.Component {\n  constructor(props) {\n    super(props);\n\n    this.state = {\n      columns: [\n        {\n          property: 'name',\n          header: {\n            label: 'Name'\n          },\n          visible: true\n        },\n        {\n          property: 'age',\n          header: {\n            label: 'Age'\n          },\n          visible: false\n        },\n        {\n          property: 'color',\n          header: {\n            label: 'Color'\n          },\n          cell: {\n            transforms: [color =\u003e ({ style: { color } })]\n          },\n          visible: true\n        }\n      ],\n      rows: [\n        {\n          id: 100,\n          name: 'Adam',\n          age: 12,\n          color: 'red'\n        },\n        {\n          id: 101,\n          name: 'Brian',\n          age: 44,\n          color: 'green'\n        },\n        {\n          id: 102,\n          name: 'Mike',\n          age: 25,\n          color: 'blue'\n        }\n      ]\n    };\n\n    this.onToggleColumn = this.onToggleColumn.bind(this);\n  }\n  render() {\n    const { columns, rows } = this.state;\n\n    return (\n      \u003cdiv\u003e\n        \u003cVisibilityToggles\n          columns={columns}\n          onToggleColumn={this.onToggleColumn}\n        /\u003e\n\n        \u003cTable.Provider\n          columns={columns.filter(column =\u003e column.visible)}\n        \u003e\n          \u003cTable.Header /\u003e\n\n          \u003cTable.Body rows={rows} rowKey=\"id\" /\u003e\n        \u003c/Table.Provider\u003e\n      \u003c/div\u003e\n    );\n  }\n  onToggleColumn({ columnIndex }) {\n    const columns = cloneDeep(this.state.columns);\n\n    columns[columnIndex].visible = !columns[columnIndex].visible;\n\n    this.setState({ columns });\n  }\n}\n\n\u003cToggleColumnsTable /\u003e\n```\n\n## License\n\nMIT. See LICENSE for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactabular%2Freact-visibility-toggles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freactabular%2Freact-visibility-toggles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactabular%2Freact-visibility-toggles/lists"}