Markdown & MDX
Learn about how QUI Docs can enhance your Markdown authoring experience.
MDX
Our framework leverages MDX to offer a powerful and flexible content authoring experience. It's an advanced Markdown format with React component support.
For example, you can use and import React components inside your markdown like this:
import {Button} from "@qualcomm-ui/react/button"
<Button emphasis="primary" variant="fill">
Hello!
</Button>Frontmatter
Frontmatter is used to add metadata to Markdown files. It's placed at the top of the Markdown file enclosed in --- lines. You can access frontmatter variables in the markdown body using the frontmatter keyword enclosed in brackets.
---
title: Example Page
---
# {frontmatter.title}
This is the content of my page.The page title must be the only h1 on the page. The pageTitle lint rule enforces this.
For a list of each available property, refer to the PageFrontmatter API.
Autolink Headings
Heading elements h2, h3, and h4 create anchor links and comprise the page's Table of Contents.
Font Styles
| Syntax | Result |
|---|---|
**bold** | bold |
_italic_ | italic |
~~strikethrough~~ | |
| `code` | code |
Lists
Lists denote nesting with alternating list styles based on the nesting level.
Ordered Lists
1. Parent
1. Child
2. Child
1. Grandchild
2. Grandchild
2. Parent
3. Parent- Parent
- Child
- Child
- Grandchild
- Grandchild
- Parent
- Parent
Unordered Lists
- Parent
- Child
- Child
- Grandchild
- Grandchild
- Parent
- Parent- Parent
- Child
- Child
- Grandchild
- Grandchild
- Parent
- Parent
Tables
| Syntax | Description | Test Text |
|-----------|-------------|-------------|
| Header | Title | Here's this |
| Paragraph | Text | And more || Syntax | Description | Test Text |
|---|---|---|
| Header | Title | Here's this |
| Paragraph | Text | And more |
Links
All Markdown links are automatically converted to clientside links. This means that the target page will be prefetched. When you click on a link, the page will be loaded on the client-side, without making a full page load (SPA routing). For example:
Click [here](/introduction) to learn more....will compile to:
import {Link} from "react-router"
Click <Link prefetch="viewport" to="/introduction">here</Link> to learn more.Relative Links
This feature was added in @qualcomm-ui/mdx-vite@5.0.0
A Markdown link with a relative path ending in .mdx is a file link. It resolves against the source MDX file on disk and automatically maps to the corresponding route in the site.
These examples use this src/routes tree with the default routing strategy:
| File path | Page URL |
|---|---|
components+/button.mdx | /components/button |
components+/tooltip.mdx | /components/tooltip |
guides+/installation.mdx | /guides/installation |
guides+/theming.mdx | /guides/theming |
From guides+/theming.mdx, link to the sibling file guides+/installation.mdx:
[Installation guide](./installation.mdx#requirements)The ./ prefix is optional: installation.mdx#requirements resolves to the same file.
From the same file, go up one level with ../ and link to components+/button.mdx:
[Button](../components+/button.mdx)File links work in GitHub's Markdown viewer and editors that follow file paths, so prefer them over root-relative links such as /api/qui-docs-config.
- The
brokenLinkslint rule validates file links. A missing target file is reported as "page not found". Fragments are checked against the target page's headings. - Knowledge exports rewrite file links to site URLs.
- Only
.mdxtargets are rewritten. Links to TSX route pages and public files use URL paths.
GitHub generates its own lowercase heading anchors. A fragment such as #navConfig opens the file but does not scroll to GitHub's #navconfig heading.
Root-relative and URL-relative links continue to work. The fileLinks lint rule defaults to "off". When enabled, it reports URL-path links to MDX pages with suggested relative .mdx replacements during development and build. Run qui-docs lint to validate links without a Vite build. Use qui-docs fix-links to apply the replacements.
Migrating Existing Links
Run qui-docs fix-links to convert URL-path links to relative .mdx file links. It applies the same replacements reported by the fileLinks lint rule:
- From
components+/button+/_button.mdx,/components/tooltip#placementbecomes../tooltip+/_tooltip.mdx#placement. - Same-page
./#sizebecomes#size.
Run the command from the docs site's package directory. Preview changes with --dry-run:
qui-docs fix-links --dry-runExample output:
src/routes/pages.mdx
30: /markdown -> ./markdown.mdx
75: /rules#frontmatter -> ./rules.mdx#frontmatter
Would fix 2 links in 1 file.Apply the changes and review the diff:
qui-docs fix-links-c, --config-file <configFile>: path to the QUI Docs config file. The file is auto-detected if omitted.--dry-run: reports changes without writing files.
The command only edits link destinations. Link text, titles, and the rest of each file remain unchanged.
- Links inside fenced code blocks and raw HTML
<a href>tags are not changed. - Links to TSX route pages, public directory files, missing pages, and external URLs are not changed.
- Pages symlinked from outside the routes directory are skipped and listed. Shared pages must keep using URL paths.
- Destinations that cannot be rewritten automatically, such as those containing escapes or character references, are listed for manual fixes.
External Links
Similarly, all links starting with https:// are converted to external links.
Check out the [official documentation](https://react.dev) to learn more....will compile to:
Check out the <a href="https://react.dev" target="_blank">here</a> to learn more.Images
All inline Markdown images are automatically converted to our ImageViewer component. Click the inline image to expand and zoom.
Store local images in the public directory at the app root and reference them with a root-relative path that starts with /. For example, public/images/nature-2.avif is referenced as /images/nature-2.avif. Omit public from the URL. Use a full https:// URL for external images.
Alerts
Our blockquotes are enhanced to enable inline alerts ala GFM.
> [!note]
> We recommend that you use [folders](https://remix.run/docs/en/main/file-conventions/routes#folders-for-organization) for organizing your routes.We recommend that you use folders for organizing your routes.
Custom Title
Use a forward slash / to add a title to the alert:
> [!note/Custom Title]
> Neat, a custom titleNeat, a custom title
Alert Variants
Customize the status color using [!note], [!tip], [!success], [!warning], or [!caution]:
We recommend that you use folders for organizing your routes.
We recommend that you use folders for organizing your routes.
We recommend that you use folders for organizing your routes.
We recommend that you use folders for organizing your routes.
Spoilers
Surround your content with a spoiler to hide it until the user clicks on the button:
::: spoiler Click to reveal
I'm a spoiler!
:::If the title is omitted, it defaults to "Open spoiler".
Serialize JSX
The ::: serialize-jsx directive wraps a JSX element with a prose description used in the knowledge export.
::: serialize-jsx
Prose description for the knowledge export.
<SomeComponent />
:::On the rendered site, only the JSX child renders. The prose is hidden. In the knowledge export (used by search and AI tools), only the prose is kept and the JSX is stripped.
Use this directive for any JSX element whose content would otherwise be absent from the knowledge export: demos, interactive widgets, and custom components that are not Demo, CodeDemo, or QdsDemo.
Steps
Added in:
Add a linear step indicator to headings using the ::: steps directive. By default, heading levels h2-h4 are given step indicators. You can change this by supplying the heading level range on the directive:
::: steps h2: only h2 headings will show the step indicator::: steps h2-h3: only h2 and h3 headings will show the step indicator
Example
Headings outside the range are not numbered. Use them to group detail inside a step. In this example, h4 headings are numbered steps and h5 headings are unnumbered sub-sections.
::: steps h4
### Install dependencies
```shell
pnpm install
```
### Start the app
```shell
pnpm dev
```
Open `http://localhost:3000` to confirm the app loads.
::: /stepsInstall dependencies
pnpm installStart the app
pnpm devOpen http://localhost:3000 to confirm the app loads.
Code Blocks
Code blocks are syntax highlighted using Shiki. We've enabled most common transformers by default, detailed below:
Diff Notation
Use [!code ++] and [!code --] to mark added and removed lines.
```ts
console.log("hewwo") // [!code --]
console.log("hello") // [!code ++]
console.log("goodbye")
```console.log("hewwo")
console.log("hello")
console.log("goodbye")Line Highlighting
Use [!code highlight] to highlight a line.
```ts
console.log("Not highlighted")
console.log("Highlighted") // [!code highlight]
console.log("Not highlighted")
```console.log("Not highlighted")
console.log("Highlighted")
console.log("Not highlighted")You can also highlight multiple lines with a single comment:
```ts
// [!code highlight:2]
console.log("Highlighted")
console.log("Highlighted")
console.log("Not highlighted")
```console.log("Highlighted")
console.log("Highlighted")
console.log("Not highlighted")Word Highlighting
Use [!code word:Hello] to highlight the word Hello in any subsequent code.
```ts
// [!code word:Hello]
const message = "Hello World"
console.log(message) // prints Hello World
```const message = "Hello World"
console.log(message) // prints Hello WorldLine Focus
Use [!code focus] to focus a line.
```ts
console.log("Not focused")
console.log("Focused") // [!code focus]
console.log("Not focused")
```console.log("Not focused")
console.log("Focused")
console.log("Not focused")You can also focus multiple lines with a single comment:
```ts
// [!code focus:2]
console.log("Focused")
console.log("Focused")
console.log("Not focused")
```console.log("Focused")
console.log("Focused")
console.log("Not focused")Error Levels
Use [!code error] and [!code warning] to mark a line with error and warning levels.
```ts
console.log("No errors or warnings")
console.error("Error") // [!code error]
console.warn("Warning") // [!code warning]
```console.log("No errors or warnings")
console.error("Error")
console.warn("Warning") Hide lines
Use [!code hide] to hide a line. Hidden lines are excluded from both the rendered output and clipboard when copied.
```ts
console.log("Not hidden")
console.log("Hidden") // [!code hide]
console.log("Not hidden")
```console.log("Not hidden")
console.log("Not hidden")You can also hide multiple lines with a single comment:
```ts
// [!code hide:2]
console.log("Hidden")
console.log("Hidden")
console.log("Not hidden")
```console.log("Not hidden")Code Tabs
Fenced code blocks with matching tabs attributes are grouped into a tabbed interface.
```shell tabs="install" label="npm"
npm install @qualcomm-ui/react
```
```shell tabs="install" label="pnpm"
pnpm install @qualcomm-ui/react
```npm install @qualcomm-ui/reactConsecutive code blocks with matching tabs values form a group. A non-code element between blocks ends the group.