Storybook addon that enables navigation between stories through programmatic links and declarative data attributes.
—
React component providing native link behavior for story navigation while preventing page reloads. Ideal for creating story navigation within React applications.
React component that renders as an anchor element with proper href and click handling for story navigation.
/**
* React component for story navigation links
* Renders as anchor element with story URL and click handling
*/
class LinkTo extends React.PureComponent<Props, State>;
interface Props {
/** Story kind (legacy, use title instead) */
kind?: StoryKind;
/** Story component title */
title?: ComponentTitle;
/** Story name (legacy, use name instead) */
story?: StoryName;
/** Story name */
name?: StoryName;
/** Link content (text, elements, etc.) */
children: ReactNode;
}
interface State {
href: string;
}Usage Examples:
import LinkTo from "@storybook/addon-links/react";
// Basic story link
<LinkTo title="Example" name="Button">
View Button Story
</LinkTo>
// Link with custom styling
<LinkTo
title="Components/Form"
name="LoginForm"
className="story-link"
style={{ color: 'blue' }}
>
Go to Login Form
</LinkTo>
// Using legacy props (still supported)
<LinkTo kind="Example" story="Button">
Button Example
</LinkTo>The LinkTo component automatically:
hrefTo to create valid story URLs for the href attributeThe component distinguishes between different types of clicks:
Click behavior:
class LinkTo extends React.PureComponent<Props, State> {
/** Called after component mounts to initialize href */
componentDidMount(): void;
/** Called after props update to refresh href if needed */
componentDidUpdate(prevProps: Props): void;
/** Updates href state based on current props */
updateHref(): Promise<void>;
/** Handles click events for story navigation */
handleClick(): void;
}The component supports both current and legacy prop naming:
| Current | Legacy | Description |
|---|---|---|
title | kind | Story component title/kind |
name | story | Individual story name |
Note: title and name are the preferred prop names. kind and story are maintained for backward compatibility.
Install with Tessl CLI
npx tessl i tessl/npm-storybook--addon-links