diff --git a/src/components/MDX/InlineCode.tsx b/src/components/MDX/InlineCode.tsx
index d206e98883c..0e8db0165b3 100644
--- a/src/components/MDX/InlineCode.tsx
+++ b/src/components/MDX/InlineCode.tsx
@@ -5,7 +5,8 @@
import cn from 'classnames';
interface InlineCodeProps {
- isLink: boolean;
+ isLink?: boolean;
+ meta?: string;
}
function InlineCode({
isLink,
diff --git a/src/components/MDX/MDXComponents.tsx b/src/components/MDX/MDXComponents.tsx
index 74ab788bac1..e12acc733e6 100644
--- a/src/components/MDX/MDXComponents.tsx
+++ b/src/components/MDX/MDXComponents.tsx
@@ -19,6 +19,7 @@ import Link from './Link';
import {PackageImport} from './PackageImport';
import Recap from './Recap';
import Sandpack from './Sandpack';
+import SandpackWithHTMLOutput from './SandpackWithHTMLOutput';
import Diagram from './Diagram';
import DiagramGroup from './DiagramGroup';
import SimpleCallout from './SimpleCallout';
@@ -432,6 +433,7 @@ export const MDXComponents = {
Recap,
Recipes,
Sandpack,
+ SandpackWithHTMLOutput,
TeamMember,
TerminalBlock,
YouWillLearn,
diff --git a/src/components/MDX/Sandpack/createFileMap.ts b/src/components/MDX/Sandpack/createFileMap.ts
index 6fc160c469b..a85059174a1 100644
--- a/src/components/MDX/Sandpack/createFileMap.ts
+++ b/src/components/MDX/Sandpack/createFileMap.ts
@@ -7,7 +7,10 @@ import type {SandpackFile} from '@codesandbox/sandpack-react/unstyled';
export const createFileMap = (codeSnippets: any) => {
return codeSnippets.reduce(
(result: Record, codeSnippet: React.ReactElement) => {
- if ((codeSnippet.type as any).mdxName !== 'pre') {
+ if (
+ (codeSnippet.type as any).mdxName !== 'pre' &&
+ codeSnippet.type !== 'pre'
+ ) {
return result;
}
const {props} = codeSnippet.props.children;
diff --git a/src/components/MDX/SandpackWithHTMLOutput.tsx b/src/components/MDX/SandpackWithHTMLOutput.tsx
new file mode 100644
index 00000000000..134da65897c
--- /dev/null
+++ b/src/components/MDX/SandpackWithHTMLOutput.tsx
@@ -0,0 +1,85 @@
+import {Children, memo} from 'react';
+import InlineCode from './InlineCode';
+import Sandpack from './Sandpack';
+
+const ShowRenderedHTML = `
+import { renderToStaticMarkup } from 'react-dom/server';
+import formatHTML from './formatHTML.js';
+
+export default function ShowRenderedHTML({children}) {
+ const markup = renderToStaticMarkup(
+
+
+
{children}
+
+ );
+ return (
+ <>
+
Rendered HTML:
+
+ {formatHTML(markup)}
+
+ >
+ );
+}`;
+
+const formatHTML = `
+import format from 'html-format';
+
+export default function formatHTML(markup) {
+ // Cheap tricks to format the HTML readably -- haven't been able to
+ // find a package that runs in browser and prettifies the HTML if it
+ // lacks line-breaks.
+ return format(markup
+ .replace('', '\\n')
+ .replace('', '\\n')
+ .replaceAll(/<\\/script>/g, '<\\/script>\\n')
+ .replaceAll(/
+```
+
+
+
+
+
+---
+
+## Reference {/*reference*/}
+
+### `
+```
+
+[See more examples below.](#usage)
+
+#### Props {/*props*/}
+
+`
+
+ >
+ );
+}
+
+export default function App() {
+ return (
+
+
+
+ );
+}
+```
+
+
diff --git a/src/content/reference/react-dom/components/title.md b/src/content/reference/react-dom/components/title.md
new file mode 100644
index 00000000000..9d6ed18ccf7
--- /dev/null
+++ b/src/content/reference/react-dom/components/title.md
@@ -0,0 +1,98 @@
+---
+title: ""
+canary: true
+---
+
+
+
+React's extensions to `` are currently only available in React's canary and experimental channels. In stable releases of React `` works only as a [built-in browser HTML component](https://react.dev/reference/react-dom/components#all-html-components). Learn more about [React's release channels here](/community/versioning-policy#all-release-channels).
+
+
+
+
+
+
+The [built-in browser `` component](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title) lets you specify the title of the document.
+
+```js
+My Blog
+```
+
+
+
+
+
+---
+
+## Reference {/*reference*/}
+
+### `` {/*title*/}
+
+To specify the title of the document, render the [built-in browser `` component](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title). You can render `` from any component and React will always place the corresponding DOM element in the document head.
+
+```js
+My Blog
+```
+
+[See more examples below.](#usage)
+
+#### Props {/*props*/}
+
+`` supports all [common element props.](/reference/react-dom/components/common#props)
+
+* `children`: `` accepts only text as a child. This text will become the title of the document. You can also pass your own components as long as they only render text.
+
+#### Special rendering behavior {/*special-rendering-behavior*/}
+
+React will always place the DOM element corresponding to the `` component within the document’s ``, regardless of where in the React tree it is rendered. The `` is the only valid place for `` to exist within the DOM, yet it’s convenient and keeps things composable if a component representing a specific page can render its `` itself.
+
+There are two exception to this:
+* If `` is within an `