Sorry, but you either have no stories or none are selected somehow.
If the problem persists, check the browser console, or the terminal you've run Storybook from.
There is no code in Carbon to implement a specific routing library, we aim to let the user decide which library to use.
React Router is one of the most popular routing libraries so we have provided examples below to help with implementing Carbon components as links using both v5 and v6 of this library. There are small but important differences in the implementation of each version.
Important: Whichever Routing library you use, when adding onClick
handlers to Link
and MenuItem
components to handle routing, it is important that the href
prop is also
provided to ensure the component renders as an HTML <a>
tag rather than a <button>
.
An example of how to use the Carbon Button
and Link
components as links with React Router v5 is shown below, this can be applied to any of the supported Carbon components.
Note the use of the useHistory
hook from react-router-dom
.
An example of how to use the Carbon Button
and Link
components as links with React Router v6 is shown below, this can be applied to any of the supported Carbon components.
Note the use of the useNavigate
hook from react-router-dom
.
There are many components that you can use this method with, including:
ActionPopoverItem
Button
Link
MenuItem
Tab
Tabs