Options
The default configuration is intentionally usable without setup. Override only the ownership, diagnostics, or naming behavior your pipeline needs.
type RehypeCodeGroupOptions = {
assets?:
| "inline"
| "none"
| { mode: "inline"; nonce?: string }
| {
mode: "external";
nonce?: string;
scriptSrc: string;
stylesheetHref: string;
};
customClassNames?: Partial<ClassNames>;
diagnostics?: "warn" | "error" | "silent";
idPrefix?: string;
labelResolver?: (label: string) => string;
};assets
Default: "inline".
| Value | Behavior |
|---|---|
"inline" | Insert styles and a classic client script only when a group exists |
"none" | Emit markup only |
{ mode: "inline", nonce } | Inline assets with a CSP nonce |
{ mode: "external", ... } | Emit external asset elements using your URLs |
customClassNames
Add classes for codeGroupClass, tabContainerClass, tabClass, activeTabClass, blockContainerClass, and activeBlockClass. Defaults remain present as stable client hooks.
diagnostics
Default: "warn".
| Value | Invalid source | Build result |
|---|---|---|
"warn" | Preserved | VFile message |
"error" | Preserved | Processing fails |
"silent" | Preserved | No diagnostic |
idPrefix
Default: "rcg". Generated IDs are deterministic within each transformation. Set a unique prefix when separately compiled fragments will be combined in one document.
labelResolver
Default: commonLabelResolver. Receives each display label and returns the rendered label. Use fullEmojiResolver from rehype-code-group/emoji for the complete shortcode catalog.
Browser client
import {
,
type ,
} from "rehype-code-group/client";
const cleanup = ();
();Repeated calls for the same root return the same cleanup function. The client automatically initializes when imported in a browser.
Package-manager options
type PackageManagerOptions = {
diagnostics?: "warn" | "error" | "silent";
packageManagers?: Array<"npm" | "pnpm" | "yarn" | "bun">;
};Public subpaths
rehype-code-group— rehype plugin and option typesrehype-code-group/remark— fence-metadata helperrehype-code-group/package-managers— npm command converterrehype-code-group/client— browser enhancer and event typesrehype-code-group/styles.css— authoritative stylesheetrehype-code-group/emoji— complete optional emoji resolver