Skip to content
mdxcn is now part of Shadcn Labs. details

annotate

Annotate

Code with numbered notes. End a line in the code block with `// (1)`, then explain it in an ordered list underneath. Marked lines stay bright and the rest fade. For a shell session, use Terminal.

use it
Good for a code sample where three lines need explaining.
instead
A shell session is Terminal. Code with nothing to explain is a plain fence.

mdx-components

End a line with `// (1)`. The ordered list under the fence explains it. Marked lines stay bright; the rest recede.

[ mdx-components.tsx ]
import { withMdxcn } from "@/registry/default/mdx/mdx"import { GraphTimeline } from "@/registry/default/graph-timeline/graph-timeline" export function useMDXComponents(components) {  return withMdxcn({ ...components, GraphTimeline })}
  1. Runs on the server. The file has no "use client".
  2. Your overrides stay. A swapped tag still reads as that tag.
<Annotate title="mdx-components.tsx">

```tsx
import { withMdxcn } from "@/registry/default/mdx/mdx" // (1)
import { GraphTimeline } from "@/registry/default/graph-timeline/graph-timeline"

export function useMDXComponents(components) {
  return withMdxcn({ ...components, GraphTimeline }) // (2)
}
```

1. Runs on the server. The file has no "use client".
2. Your overrides stay. A swapped tag still reads as that tag.

</Annotate>

install

command

retry

`# (1)` works for Python, shell, and YAML.

[ python ]
def fetch(url, times=3):    for attempt in range(times):        try:            return get(url)        except TimeoutError:            sleep(2 ** attempt)    raise
  1. Three tries. Enough for a flaky network, not for a service that is down.
  2. Only timeouts retry. A 500 fails fast.
<Annotate>

```python
def fetch(url, times=3):  # (1)
    for attempt in range(times):
        try:
            return get(url)
        except TimeoutError:  # (2)
            sleep(2 ** attempt)
    raise
```

1. Three tries. Enough for a flaky network, not for a service that is down.
2. Only timeouts retry. A 500 fails fast.

</Annotate>
[ PROPS ]
PropTypeDefaultDescription
titlestring—Defaults to the fence language, or code.
childrenMarkdown—A fenced block with `// (1)`, `# (1)`, or `<!-- (1) -->` markers, then an ordered list. Item 1 explains (1).
codestring—Data form of the fence.
notesReactNode[]—Data form of the list.
palette"mono" | "duo" | "multi""mono"mono is one accent plus muted. duo paints the second series with --graph-accent-2. multi cycles three accents.
cornerstring"+"Character at each corner of the frame.
frame"box" | "corners" | "rule" | "none""box"box draws the dashed border. corners keeps only the corner marks. rule draws dashed lines above and below. none drops the border and padding, and puts the title above the content.
classNamestring—Passed to the outer frame.