npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ai-react-markdown/mantine

v1.2.8

Published

[![npm](https://img.shields.io/npm/v/@ai-react-markdown/mantine)](https://www.npmjs.com/package/@ai-react-markdown/mantine) [![npm downloads](https://img.shields.io/npm/dm/@ai-react-markdown/mantine)](https://www.npmjs.com/package/@ai-react-markdown/manti

Readme

@ai-react-markdown/mantine

npm npm downloads license

Mantine UI integration for @ai-react-markdown/core. Provides a drop-in <MantineAIMarkdown> component that renders AI-generated markdown with Mantine-themed typography, syntax-highlighted code blocks, mermaid diagram support, and automatic color scheme detection.

What It Adds on Top of Core

  • Mantine typography -- uses Mantine's <Typography> component for consistent theming
  • Code highlighting -- renders code blocks with @mantine/code-highlight (powered by highlight.js), including tabbed views with language labels, expand/collapse, and optional auto-detection for unlabeled blocks
  • Mermaid diagrams -- mermaid code blocks are rendered as interactive SVG diagrams with dark/light theme support, toggle to source view, copy, and open-in-new-window
  • Automatic color scheme -- detects Mantine's computed color scheme (useComputedColorScheme) and passes it to the core renderer automatically
  • Mantine-scoped CSS -- extra styles wrapper overrides Mantine spacing/font-size custom properties to use relative em units, ensuring consistent scaling at any base font size

All core features (GFM, LaTeX math, CJK support, streaming, metadata context, content preprocessors, custom components) are inherited from @ai-react-markdown/core.

Installation

# npm
npm install @ai-react-markdown/mantine @ai-react-markdown/core

# pnpm
pnpm add @ai-react-markdown/mantine @ai-react-markdown/core

# yarn
yarn add @ai-react-markdown/mantine @ai-react-markdown/core

Peer Dependencies

{
  "react": ">=19",
  "react-dom": ">=19",
  "@ai-react-markdown/core": "^1.0.2",
  "@mantine/core": "^8.3.17",
  "@mantine/code-highlight": "^8.3.17",
  "highlight.js": "^11.11.1"
}

CSS Dependencies

Import the required stylesheets in your application entry point:

// Mantine core styles (required)
import '@mantine/core/styles.css';

// Mantine code highlight styles (required for code blocks)
import '@mantine/code-highlight/styles.css';

// Mantine AI Markdown styles (required for extra styles and mermaid)
import '@ai-react-markdown/mantine/styles.css';

// KaTeX styles (required for LaTeX math rendering)
import 'katex/dist/katex.min.css';

Quick Start

import { MantineProvider } from '@mantine/core';
import { CodeHighlightAdapterProvider, createHighlightJsAdapter } from '@mantine/code-highlight';
import hljs from 'highlight.js';
import MantineAIMarkdown from '@ai-react-markdown/mantine';

const highlightJsAdapter = createHighlightJsAdapter(hljs);

function App() {
  return (
    <MantineProvider>
      <CodeHighlightAdapterProvider adapter={highlightJsAdapter}>
        <MantineAIMarkdown content="Hello **world**! Math: $E = mc^2$" />
      </CodeHighlightAdapterProvider>
    </MantineProvider>
  );
}

Streaming Example

function StreamingChat({ content, isStreaming }: { content: string; isStreaming: boolean }) {
  return <MantineAIMarkdown content={content} streaming={isStreaming} />;
}

Props API Reference

MantineAIMarkdownProps<TConfig, TRenderData>

Extends AIMarkdownProps from the core package. All core props are supported; listed below are the inherited props with Mantine-specific default overrides:

| Prop | Type | Default | Description | | ---------------------- | -------------------------------- | -------------------------------------- | -------------------------------------------------------------------- | | content | string | (required) | Raw markdown content to render. | | streaming | boolean | false | Whether content is actively being streamed. | | fontSize | number \| string | '0.875rem' | Base font size. Numbers are treated as pixels. | | variant | AIMarkdownVariant | 'default' | Typography variant name. | | colorScheme | AIMarkdownColorScheme | Auto-detected | Color scheme. Defaults to Mantine's computed color scheme. | | config | PartialDeep<TConfig> | undefined | Partial render config, deep-merged with defaults. | | defaultConfig | TConfig | defaultMantineAIMarkdownRenderConfig | Base config. | | metadata | TRenderData | undefined | Arbitrary data for custom components via dedicated context. | | contentPreprocessors | AIMDContentPreprocessor[] | [] | Additional preprocessors after the built-in LaTeX preprocessor. | | customComponents | AIMarkdownCustomComponents | Mantine defaults | Component overrides, merged with Mantine's built-in <pre> handler. | | Typography | AIMarkdownTypographyComponent | MantineAIMarkdownTypography | Typography wrapper. | | ExtraStyles | AIMarkdownExtraStylesComponent | MantineAIMDefaultExtraStyles | Extra style wrapper. |

Mantine-Specific Configuration

The Mantine package extends the core AIMarkdownRenderConfig with additional options:

MantineAIMarkdownRenderConfig

Inherits all core config fields plus:

| Field | Type | Default | Description | | ------------------------------------- | --------- | ------- | ------------------------------------------------------------------- | | codeBlock.defaultExpanded | boolean | true | Whether code blocks start expanded. | | codeBlock.autoDetectUnknownLanguage | boolean | false | Use highlight.js to auto-detect language for unlabeled code blocks. |

Example: Collapsed Code Blocks

<MantineAIMarkdown
  content={markdown}
  config={{
    codeBlock: { defaultExpanded: false },
  }}
/>

Hooks

useMantineAIMarkdownRenderState<TConfig>()

Typed wrapper around the core useAIMarkdownRenderState hook, defaulting to MantineAIMarkdownRenderConfig. Accepts an optional generic parameter for further extension.

import { useMantineAIMarkdownRenderState } from '@ai-react-markdown/mantine';

function MyCodeBlock() {
  const { config, streaming, colorScheme } = useMantineAIMarkdownRenderState();
  const isExpanded = config.codeBlock.defaultExpanded;
  // ...
}

useMantineAIMarkdownMetadata<TMetadata>()

Typed wrapper around the core useAIMarkdownMetadata hook, defaulting to MantineAIMarkdownMetadata. Accepts an optional generic parameter for further extension. Metadata lives in a separate React context from render state, so metadata updates do not cause re-renders in components that only consume render state.

import { useMantineAIMarkdownMetadata } from '@ai-react-markdown/mantine';

function MyComponent() {
  const metadata = useMantineAIMarkdownMetadata();
  // Access metadata fields
}

Code Highlighting Setup

Code highlighting requires a CodeHighlightAdapterProvider wrapping your component tree. This is a Mantine requirement -- the adapter bridges highlight.js into Mantine's code highlight components.

import { CodeHighlightAdapterProvider, createHighlightJsAdapter } from '@mantine/code-highlight';
import hljs from 'highlight.js';

const highlightJsAdapter = createHighlightJsAdapter(hljs);

function App() {
  return (
    <CodeHighlightAdapterProvider adapter={highlightJsAdapter}>
      {/* MantineAIMarkdown components can be rendered anywhere below */}
    </CodeHighlightAdapterProvider>
  );
}

Language Auto-Detection

By default, code blocks without an explicit language annotation render as plaintext. Enable auto-detection via config:

<MantineAIMarkdown content={markdown} config={{ codeBlock: { autoDetectUnknownLanguage: true } }} />

This uses highlight.js's highlightAuto to guess the language. Results may vary for short or ambiguous snippets.

Mermaid Diagram Support

Fenced code blocks with the mermaid language identifier are automatically rendered as interactive SVG diagrams:

```mermaid
graph TD
  A[Start] --> B{Decision}
  B -->|Yes| C[OK]
  B -->|No| D[Cancel]
```

Features:

  • Automatic dark/light theme switching based on Mantine's color scheme
  • Toggle between rendered diagram and raw source code
  • Copy button for the mermaid source
  • Click the rendered diagram to open the SVG in a new window
  • Chart type label displayed in the header
  • Graceful fallback to source code display on parse errors

The mermaid library is a direct dependency of this package -- no additional installation is needed.

Color Scheme Integration

MantineAIMarkdown automatically detects Mantine's computed color scheme using useComputedColorScheme('light'). You can override this by passing an explicit colorScheme prop:

// Automatic (default) -- follows Mantine's color scheme
<MantineAIMarkdown content={markdown} />

// Explicit override
<MantineAIMarkdown content={markdown} colorScheme="dark" />

The color scheme is passed to:

  • The core <AIMarkdown> component for typography theming
  • Mermaid diagram rendering (dark/base theme selection)
  • The extra styles wrapper for color-aware CSS

Custom Components

Custom component overrides are merged with the Mantine defaults. Your overrides take precedence:

import MantineAIMarkdown from '@ai-react-markdown/mantine';
import type { AIMarkdownCustomComponents } from '@ai-react-markdown/core';

const customComponents: AIMarkdownCustomComponents = {
  a: ({ href, children }) => (
    <a href={href} target="_blank" rel="noopener noreferrer">
      {children}
    </a>
  ),
};

<MantineAIMarkdown content={markdown} customComponents={customComponents} />;

To override the default <pre> handler (and lose built-in code highlighting and mermaid support), include pre in your custom components.

Exported API

Default Export

  • MantineAIMarkdown -- the main component (memoized)

Components

  • MantineAIMarkdownTypography -- Mantine-themed typography wrapper
  • MantineAIMDefaultExtraStyles -- default extra styles wrapper with Mantine CSS scoping

Types

  • MantineAIMarkdownProps
  • MantineAIMarkdownRenderConfig
  • MantineAIMarkdownMetadata

Constants

  • defaultMantineAIMarkdownRenderConfig -- default Mantine render config (frozen)

Hooks

  • useMantineAIMarkdownRenderState<TConfig>() -- typed render state access
  • useMantineAIMarkdownMetadata<TMetadata>() -- typed metadata access

Core Package

For base features, configuration options, content preprocessors, TypeScript generics, and architecture details, see the @ai-react-markdown/core README.

License

MIT