{"id":15634889,"url":"https://github.com/oklas/react-breadcrumbs-dynamic","last_synced_at":"2025-04-06T03:10:07.863Z","repository":{"id":40790813,"uuid":"95704503","full_name":"oklas/react-breadcrumbs-dynamic","owner":"oklas","description":":house_with_garden: \u003e breadcrumbs \u003e extremely flexible \u003e and \u003e easy to use","archived":false,"fork":false,"pushed_at":"2022-12-09T13:40:23.000Z","size":2537,"stargazers_count":126,"open_issues_count":35,"forks_count":30,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-30T02:08:20.096Z","etag":null,"topics":["breadcrumb","breadcrumb-navigation","breadcrumbs","breadcrumbs-dynamic","breadcrumbs-flexible","breadcrumbs-item","react","theme"],"latest_commit_sha":null,"homepage":"","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/oklas.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-06-28T19:31:37.000Z","updated_at":"2024-08-15T10:37:15.000Z","dependencies_parsed_at":"2023-01-25T21:31:42.238Z","dependency_job_id":null,"html_url":"https://github.com/oklas/react-breadcrumbs-dynamic","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/oklas%2Freact-breadcrumbs-dynamic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oklas%2Freact-breadcrumbs-dynamic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oklas%2Freact-breadcrumbs-dynamic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oklas%2Freact-breadcrumbs-dynamic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oklas","download_url":"https://codeload.github.com/oklas/react-breadcrumbs-dynamic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427006,"owners_count":20937201,"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":["breadcrumb","breadcrumb-navigation","breadcrumbs","breadcrumbs-dynamic","breadcrumbs-flexible","breadcrumbs-item","react","theme"],"created_at":"2024-10-03T10:58:44.103Z","updated_at":"2025-04-06T03:10:07.845Z","avatar_url":"https://github.com/oklas.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-breadcrumbs-dynamic\n\n[![Npm package](https://img.shields.io/npm/v/react-breadcrumbs-dynamic.svg?style=flat)](https://npmjs.com/package/react-breadcrumbs-dynamic)\n[![Npm downloads](https://img.shields.io/npm/dm/react-breadcrumbs-dynamic.svg?style=flat)](https://npmjs.com/package/react-breadcrumbs-dynamic)\n[![Travis build status](http://img.shields.io/travis/oklas/react-breadcrumbs-dynamic.svg?style=flat)](https://travis-ci.org/oklas/react-breadcrumbs-dynamic)\n[![Test Coverage](https://img.shields.io/codecov/c/github/oklas/react-breadcrumbs-dynamic.svg)](https://codecov.io/gh/oklas/react-breadcrumbs-dynamic)\n[![Dependency Status](https://david-dm.org/oklas/react-breadcrumbs-dynamic.svg)](https://david-dm.org/oklas/react-breadcrumbs-dynamic)\n[![Dependency Status](https://img.shields.io/github/stars/oklas/react-breadcrumbs-dynamic.svg?style=social\u0026label=Star)](https://github.com/oklas/react-breadcrumbs-dynamic)\n[![Dependency Status](https://img.shields.io/twitter/follow/oklaspec.svg?style=social\u0026label=Follow)](https://twitter.com/oklaspec)\n\n\n***\n\n[`🏠`](https://oklas.github.io/react-breadcrumbs-dynamic) \u003e [`React dynamic breadcrumbs`](https://oklas.github.io/react-breadcrumbs-dynamic) \u003e [`extremely flexible`](https://oklas.github.io/react-breadcrumbs-dynamic) \u003e [`and`](https://oklas.github.io/react-breadcrumbs-dynamic) \u003e [`easy to use`](https://oklas.github.io/react-breadcrumbs-dynamic)\n\n\nThis is completely router-independent solution. You can use it with any version\nof React Router (2 or 3 or 4) or any other routing library for React or without\nrouting at all. All what you need is just to specify components for breadcrumbs\nitems and its props. However props and components should be specified\n[separately](https://github.com/oklas/react-through#readme). Props should be specified\nin intermediator component `BreadcrumbsItem` anywhere in your hierarchy of\ncomponents and routes.\n\nVisit live **[DEMO](//oklas.github.io/react-breadcrumbs-dynamic)** (source code\nof demo in [example](example/src) folder)\n\n# Synopsis\n\n```js\nconst Profile = ({user}) =\u003e (\n  \u003cdiv\u003e\n\n    \u003cBreadcrumbsItem\n      to=`/user/${user.login}`\n      icon='account-box'\n    \u003e\n      {user.firstName} {user.lastName}\n    \u003c/BreadcrumbsItem\u003e\n\n    \u003ch1\u003e\n      {user.firstName} {user.lastName}\n    \u003c/h1\u003e\n  \u003c/div\u003e\n)\n```\n\n# Installation\n\n``` sh\nnpm install --save react-through react-breadcrumbs-dynamic\n\n# definitions may be installed if typescript is used\n# ( worked for 1.0.10, leave feedback if any )\nnpm install --save @types/react-breadcrumbs-dynamic\n```\n\n# Base configuration\n\nDo you already use declarative communications through react tree with\n[react-through](https://github.com/oklas/react-through#readme)?\nJust add `\u003cThroughProvider/\u003e` to the root of your React component tree:\n\n``` javascript\nimport {ThroughProvider} from 'react-through'\n\nconst theApp = (\n  \u003cThroughProvider\u003e\n    \u003cApp /\u003e\n  \u003c/ThroughProvider\u003e\n)\n\nReactDOM.render(theApp, document.getElementById('root'))\n```\n\n\n# Instance configuration\n\nIn this example the `react-router` v4 `\u003cNavLink\u003e` is used as breadcrumbs item:\n\n``` javascript\nimport {Breadcrumbs} from 'react-breadcrumbs-dynamic'\n\nconst Page = (props) =\u003e (\n  return (\n    \u003cdiv className=\"App\"\u003e\n      \u003cHeader\u003e\n\n        \u003cBreadcrumbs\n          separator={\u003cb\u003e / \u003c/b\u003e}\n          item={NavLink}\n          finalItem={'b'}\n          finalProps={{\n            style: {color: 'red'}\n          }}\n        /\u003e\n\n      \u003c/Header\u003e\n\n      {props.children}\n\n      \u003cFooter\u003e\n        \u003cBreadcrumbs/\u003e\n      \u003c/Footer\u003e\n    \u003c/div\u003e\n  )\n}\n```\n\nPlease note that `item` and `finalItem` require react component (class) instead\nof react element. However `separator` requires react element.\n\nBy default order of items is based on URL length. You can override the sort order\nas you like just specify comparision function in `compare` prop which receive\npair of objects containing props of breadcrumbs item. For example:\n`\u003cBreadcrumbs compare={(a,b)=\u003ea.weight-b.weight} removeProps={{weight: true}} /\u003e`.\n\nIf you use `\u003ca\u003e` tag based items then you will find `renameProps` or\n`duplicateProps` useful to map prop `to` on prop `href` like this:\n`\u003cBreadcrumbs renameProps={{to:\"href\"}} /\u003e`.\n\n\n# Adding items to breadcrumbs\n\nEach routed component in your react tree is generally associated with route\nand with correspondent breadcrumbs. Each component may add its breadcrumbs\nitem by rendering `\u003cBreadcrumbsItem\u003e` with any props and children.\n\nExample tree of routed components with breadcrumbs items:\n\n``` javascript\nimport {BreadcrumbsItem} from 'react-breadcrumbs-dynamic'\n\nconst App = (props) =\u003e (\n  \u003cdiv\u003e\n    \u003cBreadcrumbsItem to='/'\u003eMain Page\u003c/BreadcrumbsItem\u003e\n    {props.children}\n    \u003cRoute exact path=\"/user\" component={User} /\u003e\n  \u003c/div\u003e\n)\n\nconst User = (props) =\u003e (\n  \u003cdiv\u003e\n    \u003cBreadcrumbsItem to='/user'\u003eHome\u003c/BreadcrumbsItem\u003e\n    \u003ch2\u003eHome\u003c/h2\u003e\n    {props.children}\n    \u003cRoute exact path=\"/user/contacts\" component={Contacts} /\u003e\n  \u003c/div\u003e\n)\n\nconst Contacts = (props) =\u003e (\n  \u003cdiv\u003e\n    \u003cBreadcrumbsItem to='/user/contacts'\u003eContacts\u003c/BreadcrumbsItem\u003e\n    \u003ch2\u003eContacts\u003c/h2\u003e\n    ...\n  \u003c/div\u003e\n)\n```\n\nYou can declaratively pass props with any data, functions, components and so on\nthrough react tree in any direction because\n[react-through](https://github.com/oklas/react-through#readme) allows to do that.\n\n\n# Result\n\nThe result of above code will represent breadcrumbs like this:\n\n``` javascript\n  \u003cNavLink to='/'\u003eMain Page\u003c/NavLink\u003e\n  \u003cb\u003e / \u003c/b\u003e\n  \u003cNavLink to='/user'\u003eHome\u003c/NavLink\u003e\n  \u003cb\u003e / \u003c/b\u003e\n  \u003cb to='/user/contacts'\u003eContacts\u003c/b\u003e\n```\n\nIf you use library or if you think that it is good for use -\nlet people know about that - click the star.\n\n___\n\n\n# The components and functions\n\n## `Breadcrumbs` component props\n\nThe breadcrumbs instance is implemented in the `Breadcrumbs` component, which\nis the `through container` in terms of\n[react-through](https://github.com/oklas/react-through#readme).\n\n| property | type | default | description |\n| -------- | ---- | ------- | ------- |\n| `separator` | *element* | `undefined` | separator between breadcrumbs items |\n| `item` | *component* | `a` | component of breadcrumbs items |\n| `finalItem` | *component* | value of `item` prop | component of final breadcrumbs item |\n| `finalProps` | *object* | `{}` | final item props - will override specified in `BreadcrumbsItem` |\n| `container` | *component* | `span` | wrapper component |\n| `containerProps` | *object* | `{}` | props for `container` component |\n| `compare` | *function* | (a,b)=\u003ea.to.length-b.to.length | comparision function for sorting items |\n| `hideIfEmpty` | *boolean* | `false` | show or hide breadcrumbs container if items exist or not |\n| `renameProps` | *object* | `{}` | rename props passed from item `BreadcrumbsItem` to `item` |\n| `duplicateProps` | *object* | `{}` | duplicate props passed from item `BreadcrumbsItem` to `item` |\n| `removeProps` | *object* | `{}` | props aren't passed from item `BreadcrumbsItem` to `item` |\n\n\n## `BreadcrumbsItem` component props\n\nThe `BreadcrumbsItem` component is the `through agent` with bearing key in\nprop `to` in terms of [react-through](https://github.com/oklas/react-through#readme).\n\nThe `BreadcrumbsItem` component may have any prop and may have children. Each prop\nfor `BreadcrumbsItem` will be passed to correspondent breadcrumb component specified\nin `item` or `finalItem` prop of `Breadcrumbs`. Only one prop is mandatory.\n\n| property | type | default | description |\n| -------- | ---- | ------- | ------- |\n| `to` | *string* | required | mandatory required bearing key with URL |\n| `...` | *any* | | any properties - will be mapped to correspondent breadcrumb item |\n\n___\n\n\n### `withBreadcrumbsItem()` function\n\nAdvanced usage higher order component function. It acquire one argument with\nyour custom react component and return appropriate component which will have\n`breadcrumbs` in its props with methods `item()` and `items()` like\n`throughAgent` from [react-through](https://github.com/oklas/react-through#readme).\n\n\n### `this.props.breadcrumbs.item()` and `this.props.breadcrumbs.items()`\n\nAdvanced usage methods to configure breadcrumbs item of your react component.\nThese methods will be added to props by HOC of `withBreadcrumbsItem` function.\nThe function `item()` accepts one react component with props and the functions\n`items()` accepts react component with children which may contain any number of\ncomponents to create correspondent number of breadcrumbs item. The breadcrumbs\nitem for these functions may be any react component and only props is\nsignificant. The `Dummy` and the `Item` components is exported by library\nfor this case. Each function accepts null to reset breadcrumbs items to none if\ncurrent component is no more needed to represent any breadcrumbs items.\n\n\n### constants\n\nThe `through area` name  used by this library is defined in\n`breadcrumbsThroughArea` variable.\n\nThe prop name which contain bearing key is defined in\n`breadcrumbsBearingKey`.\n\n\n``` javascript\nimport { breadcrumbsThroughArea } from 'react-breadcrumbs-dynamic'\nimport { breadcrumbsBearingKey } from 'react-breadcrumbs-dynamic'\n```\n\n\n## LICENSE\n\n#### [MIT](./LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foklas%2Freact-breadcrumbs-dynamic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foklas%2Freact-breadcrumbs-dynamic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foklas%2Freact-breadcrumbs-dynamic/lists"}