{"id":23058675,"url":"https://github.com/suhdev/sh-react-sidebar","last_synced_at":"2026-04-10T01:05:00.857Z","repository":{"id":57357500,"uuid":"77801158","full_name":"suhdev/sh-react-sidebar","owner":"suhdev","description":"A Configurable Sidebar Component written in TypeScript. ","archived":false,"fork":false,"pushed_at":"2017-01-11T22:47:38.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-06T21:47:34.952Z","etag":null,"topics":["react","sidebar","typescript","ui-components"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/suhdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-01T23:25:26.000Z","updated_at":"2017-03-04T21:45:57.000Z","dependencies_parsed_at":"2022-09-26T16:32:25.543Z","dependency_job_id":null,"html_url":"https://github.com/suhdev/sh-react-sidebar","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/suhdev%2Fsh-react-sidebar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suhdev%2Fsh-react-sidebar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suhdev%2Fsh-react-sidebar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suhdev%2Fsh-react-sidebar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/suhdev","download_url":"https://codeload.github.com/suhdev/sh-react-sidebar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246944383,"owners_count":20858772,"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":["react","sidebar","typescript","ui-components"],"created_at":"2024-12-16T02:16:57.780Z","updated_at":"2025-12-30T23:10:09.310Z","avatar_url":"https://github.com/suhdev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sh-react-sidebar\n\nA configurable sidebar ReactJS component written in TypeScript. \n\n## Usage \n\n\n### For browser use: \n\nInclude the minified JavaScript file in your HTML after inclusion of React library. \nAssuming React and ReactDOM are loaded before the Sidebar. \n```html \n    \u003clink rel=\"stylesheet\" href=\"__PATH_TO_CSS__/sidebar.min.css\"\u003e\u003c/script\u003e\n    \u003cscript type=\"text/javascript\" src=\"__PATH_TO_LIB__/sidebar.min.js\"\u003e\u003c/script\u003e\n\n\n    \u003cscript type=\"text/javascript\"\u003e\n    var sidebar = null;\n    var items = [{\n        label:'item-1',\n        key:'item-1',\n        href:'#item-1'\n    },{\n        label:'item-2',\n        key:'item-2',\n        href:'#item-2'\n    },{\n        label:'item-3',\n        key:'item-3',\n        href:'#item-3'\n    }]; \n\n    function update(selected:item){\n        ReactDOM.render(\n        sidebar = React.createElement(ShReact.Sidebar,{\n            className:'my-class',\n            items:items,\n            selected:selected,\n            onItemClick:onClick,\n        }),document.getElementById('SidebarContainer'));\n    }\n\n    function onClick(item,index){\n        update(item); \n    }\n    sidebar = ReactDOM.render(\n        React.createElement(ShReact.Sidebar,{\n            className:'my-class',\n            items:items,\n            selected:items[0],\n            onItemClick:onClick,\n        }),document.getElementById('SidebarContainer'));\n     \n    \u003c/script\u003e \n\n```\n\n### For webpack use:\n\n```typescript\n\n    const React = require('react'); \n    const ReactDOM = require('react-dom'); \n    const Sidebar = require('sh-react-sidebar').Sidebar; \n\n    var items = [{\n        label:'item-1',\n        key:'item-1',\n        href:'#item-1'\n    },{\n        label:'item-2',\n        key:'item-2',\n        href:'#item-2'\n    },{\n        label:'item-3',\n        key:'item-3',\n        href:'#item-3'\n    }]; \n\n    function onClick(item,index){\n        console.log(item);\n    }\n\n    let sidebar = ReactDOM.render(\u003cSidebar \n        items={items} \n        selected={items[0]} \n        onItemClick={onClick} /\u003e,\n        document.getElementById('SidebarContainer')); \n\n```\n\n\n### For JSPM use:\n\n```typescript  \n\n    import * as React from 'react'; \n    import * as ReactDOM from 'react-dom'; \n    import {Sidebar} from 'sh-react-sidebar'; \n\n    var items = [{\n        label:'item-1',\n        key:'item-1',\n        href:'#item-1'\n    },{\n        label:'item-2',\n        key:'item-2',\n        href:'#item-2'\n    },{\n        label:'item-3',\n        key:'item-3',\n        href:'#item-3'\n    }]; \n\n    function onClick(item,index){\n        console.log(item);\n    }\n\n    let sidebar = ReactDOM.render(\u003cSidebar \n        items={items} \n        selected={items[0]} \n        onItemClick={onClick} /\u003e,\n        document.getElementById('SidebarContainer'));  \n\n``` \n\n\n## Available Options \n\n1. `items` an array of items to be used as the source of information for the sidebar. By default each item is expected to implement the following interface. \n\n```javascript\n\ninterface ItemDef {\n    key:string;\n    label:string;\n    href:string;\n}\n\n```\n\nAlternatively, an array of arbitrary object can be provided, given that `getLabelForItem` and `getKeyForItem` are provided. \n\n2. `getLabelForItem(item,index)` is a function that will be called for every item in the array to get its label. \n3. `getKeyForItem(item,index)` is a function that will be called for every item in the array to get its key. \n\n4. `className` an optional class name to be added to the slider root DOMElement. \n5. `hasSearch` an optional boolean, when set to true, a search field will be added to the sidebar. \n6. `placeholder` an optional string to be used for the search field. \n7. `emptyLine` an optional string to be used when no items match the search string. \n8. `isLoading` an optional boolean that states whether the sidebar is ready to show the items or it is loading. This is useful for ajax populated sidebars. \n9. `preloaderString` an optional string to be used while in loading mode. \n10. `preloader` an optional that can be either a function that returns a ReactElement or a react element to be shown when in loading mode. \n11. `selected` the currently selected item from the list of items. \n12. `onItemClick` a function that gets passed the clicked item and its index.\n13. `getViewForItem` an optional that is when provided will be used to generate views for items, the function gets called with the `item` and its `index`. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuhdev%2Fsh-react-sidebar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuhdev%2Fsh-react-sidebar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuhdev%2Fsh-react-sidebar/lists"}