CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-mantine--code-highlight

React component library for syntax highlighting code blocks and inline code with Mantine theme integration

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

inline-highlighting.mddocs/

Inline Code Highlighting

The InlineCodeHighlight component provides syntax highlighting for short code snippets within text content, designed to integrate seamlessly with surrounding text.

Capabilities

InlineCodeHighlight Component

Component for highlighting short code snippets within text content.

/**
 * Component for highlighting short code snippets within text content
 * @param props - Configuration options for the inline code highlight component
 * @returns Rendered inline code element
 */
function InlineCodeHighlight(props: InlineCodeHighlightProps): JSX.Element;

interface InlineCodeHighlightProps extends 
  BoxProps,
  StylesApiProps<InlineCodeHighlightFactory>,
  ElementProps<'code'> {
  /** Code to highlight */
  code: string;
  /** Language of the code, used to determine syntax highlighting */
  language?: string;
  /** Controls background color of the code. By default, the value depends on color scheme. */
  background?: MantineColor;
  /** Key of theme.radius or any valid CSS value to set border-radius @default 'sm' */
  radius?: MantineRadius;
  /** Adds border to the root element @default false */
  withBorder?: boolean;
}

Usage Examples:

import { InlineCodeHighlight } from "@mantine/code-highlight";

// Basic inline code
function BasicInline() {
  return (
    <p>
      Use the <InlineCodeHighlight code="useState" language="javascript" /> hook 
      to manage state in React components.
    </p>
  );
}

// With custom styling
function StyledInline() {
  return (
    <p>
      The method{" "}
      <InlineCodeHighlight
        code="Array.prototype.map()"
        language="javascript"
        background="blue.0"
        radius="md"
        withBorder
      />{" "}
      transforms array elements.
    </p>
  );
}

// In documentation
function DocumentationExample() {
  return (
    <div>
      <h3>API Reference</h3>
      <p>
        Call <InlineCodeHighlight code="fetchData()" language="typescript" /> to 
        retrieve data from the server. The function returns a{" "}
        <InlineCodeHighlight code="Promise<ApiResponse>" language="typescript" />.
      </p>
    </div>
  );
}

// Different languages
function LanguageExamples() {
  return (
    <ul>
      <li>
        Python: <InlineCodeHighlight code="len(array)" language="python" />
      </li>
      <li>
        JavaScript: <InlineCodeHighlight code="array.length" language="javascript" />
      </li>
      <li>
        CSS: <InlineCodeHighlight code="display: flex" language="css" />
      </li>
    </ul>
  );
}

Factory Types

type InlineCodeHighlightFactory = Factory<{
  props: InlineCodeHighlightProps;
  ref: HTMLElement;
  stylesNames: InlineCodeHighlightStylesNames;
  vars: InlineCodeHighlightCssVariables;
}>;

type InlineCodeHighlightStylesNames = 'inlineCodeHighlight';

type InlineCodeHighlightCssVariables = {
  inlineCodeHighlight: '--ch-background' | '--ch-radius';
};

Integration Notes

  • The InlineCodeHighlight component renders as a <code> element by default
  • It inherits text properties from surrounding content (font-size, line-height, etc.)
  • Styling integrates with Mantine's theme system for consistent appearance
  • Supports all standard Mantine styling patterns (classNames, styles, etc.)
  • Uses the same highlighting system as CodeHighlight but optimized for inline display

docs

adapters.md

code-highlighting.md

code-tabs.md

custom-controls.md

index.md

inline-highlighting.md

tile.json