Skip to main content
ESC

Tags

Tags are React components responsible for rendering markdown elements. By default, Robindoc uses built-in components for all markdown elements, but you can overwrite any tag to customize the rendering behavior.

Usage 

Tags are passed to the Page component via the tags prop. You can overwrite individual tags while keeping the default implementation for others.

TypeScript
JavaScript
import { Page } from "./robindoc";

const CustomParagraph = ({ children, ...props }) => (
<p {...props} className="custom-paragraph">
{children}
</p>
);

const DocsPage = () => (
<Page
pathname="/docs"
tags={{
Paragraph: CustomParagraph,
}}
/>
);

export default DocsPage;
import { Page } from "./robindoc";

const CustomParagraph = ({ children, ...props }) => (
<p {...props} className="custom-paragraph">
{children}
</p>
);

const DocsPage = () => (
<Page
pathname="/docs"
tags={{
Paragraph: CustomParagraph,
}}
/>
);

export default DocsPage;

Available Tags 

All tags accept standard React props, including className and children where applicable. The following tags can be overwritten:

Text Elements 

Headings 

Lists 

Code Blocks 

Tables 

Other Elements 

Examples 

Custom Paragraph Styling 

Add custom attributes or styling to paragraphs:

TypeScript
JavaScript
import { Page } from "./robindoc";

const DocsPage = () => (
<Page
pathname="/docs"
tags={{
Paragraph: (props) => <p {...props} data-test="paragraph" />,
}}
/>
);

export default DocsPage;
import { Page } from "./robindoc";

const DocsPage = () => (
<Page
pathname="/docs"
tags={{
Paragraph: (props) => <p {...props} data-test="paragraph" />,
}}
/>
);

export default DocsPage;

Custom Heading Component 

Replace the default heading implementation:

TypeScript
JavaScript
import { Page } from "./robindoc";

const CustomHeading = ({ component: Component, children, ...props }) => (
<Component {...props} className="custom-heading">
<span className="heading-prefix">→</span>
{children}
</Component>
);

const DocsPage = () => (
<Page
pathname="/docs"
tags={{
Heading: CustomHeading,
AnchorHeading: CustomHeading,
}}
/>
);

export default DocsPage;
import { Page } from "./robindoc";

const CustomHeading = ({ component: Component, children, ...props }) => (
<Component {...props} className="custom-heading">
<span className="heading-prefix">→</span>
{children}
</Component>
);

const DocsPage = () => (
<Page
pathname="/docs"
tags={{
Heading: CustomHeading,
AnchorHeading: CustomHeading,
}}
/>
);

export default DocsPage;

Implementation Details 

Tags are merged with default implementations using object spread syntax. When you provide a custom tag, it completely replaces the default component for that specific tag. Other tags continue to use their default implementations.

const Tags = { ...DEFAULT_TAGS, ...userTags };

This means you can overwrite as many or as few tags as needed. The custom component receives the same props as the default implementation, ensuring compatibility with Robindoc's internal rendering logic.

Note

When overwriting tags, ensure your custom components accept the same props as the default implementations. Refer to the source code or TypeScript definitions for exact prop interfaces.

Tip

You can import default tag components from robindoc to use as a base for your custom implementations, allowing you to extend rather than completely replace functionality.

PreferencesBuild-in blocks
Return to navigation