Skip to Content
rehype-code-group

Options

Every option accepted by the rehype plugin and satteriCodeGroup, with types and defaults.

The rehype plugin and satteriCodeGroup take the same options object, RehypeCodeGroupOptions. Every option is optional.

import rehypeCodeGroup, { type RehypeCodeGroupOptions } from "rehype-code-group";

const options: RehypeCodeGroupOptions = {
  assets: "none",
  diagnostics: "error",
  idPrefix: "docs",
};

unified().use(rehypeCodeGroup, options);

Prop

Type

assets

Chooses how the client and stylesheet reach the page. Assets are only added to documents that contain a group.

ValueAdds
"inline"A <style> and a classic <script type="text/javascript"> with the full assets.
{ mode: "inline", nonce }The same, with nonce on both elements.
{ mode: "external", stylesheetHref, scriptSrc, nonce? }<link rel="stylesheet" href> and <script type="module" src>.
"none"Nothing. Import rehype-code-group/client and /styles.css yourself.

Assets go into the document's <head>. If there is an <html> element without a <head>, one is created. For fragments, they are added at the start of the tree. See Asset delivery and CSP.

diagnostics

Applies to compact groups whose number of labels differs from the number of blocks. The group is always left unconverted.

  • "warn": adds a vfile message with source rehype-code-group and rule panel-count.
  • "error": fails the file with the same message, which usually fails the build.
  • "silent": no message.

Malformed rich groups, and compact groups that the plugin doesn't recognize at all, are left unconverted without a message. On Sätteri, see Sätteri diagnostics.

idPrefix

Tabs get IDs like rcg-0-tab-1 and panels like rcg-0-block-1: the prefix, the group number in the file, then the tab number. Numbering starts at 0 for each file and is the same on every build. Set a different prefix for each fragment when several separately processed fragments share a page.

labelResolver

Called once for each tab label. The default, commonLabelResolver, replaces five emoji shortcodes. fullEmojiResolver from rehype-code-group/emoji supports the full catalog. See Labels and emoji.

customClassNames

Prop

Type

The defaults in this table are always applied. Your values are added after them, and may contain several space-separated classes. See Styling.

Package-manager plugin options

rehype-code-group/package-managers takes its own options, PackageManagerOptions:

Prop

Type

The remark companion, rehype-code-group/remark, and satteriCodeGroupLabels take no options.

Edit on GitHub