CodeInline
Renders an inline code element with optional syntax highlighting and copy button.
In React, <span style={{ color: 'blue' }} /> changes the color of the text to blue.
import { CodeInline } from 'renoun' export function Basic() { return ( <p> In React,{' '} <CodeInline language="jsx">{`<span style={{ color: 'blue' }} />`}</CodeInline>{' '} changes the color of the text to blue. </p> ) }
In development, the component uses a Suspense fallback to render immediately while asynchronous syntax highlighting and analysis load in the background. In production, it renders the fully-resolved code block directly.
MDX Inline Code
When using MDX with the rehypePlugins from renoun/mdx you can prefix the inline code with a language similar to fenced code blocks. For example:
When using inline code `js console.log('Hello, World!')`, you can specify the language for syntax highlighting.
When using inline code js console.log('Hello, World!'), you can specify the language for syntax highlighting.
Examples
Allow Copy
View Sourcenpx create-renounimport { CodeInline } from 'renoun' export function AllowCopy() { return ( <CodeInline allowCopy language="sh" paddingX="0.8em" paddingY="0.5em"> npx create-renoun </CodeInline> ) }
API Reference
Properties
| Property | Type | Modifiers |
|---|---|---|
| children | string | — |
Code snippet to be highlighted. | ||
| language? | "abap" | "actionscript-3" | "ada" | "angular-html" | "angular-ts" | "apache" | "apex" | "apl" | "applescript" | "ara" | "asciidoc" | "adoc" | "asm" | "astro" | "awk" | "ballerina" | "bat" | "batch" | "beancount" | "berry" | "be" | "bibtex" | "bicep" | "blade" | "bsl" | "1c" | "c" | "cadence" | "cdc" | "cairo" | "clarity" | "clojure" | "clj" | "cmake" | "cobol" | "codeowners" | "codeql" | "ql" | "coffee" | "coffeescript" | "common-lisp" | "lisp" | "coq" | "cpp" | "c++" | "crystal" | "csharp" | "c#" | "cs" | "css" | "csv" | "cue" | "cypher" | "cql" | "d" | "dart" | "dax" | "desktop" | "diff" | "docker" | "dockerfile" | "dotenv" | "dream-maker" | "edge" | "elixir" | "elm" | "emacs-lisp" | "elisp" | "erb" | "erlang" | "erl" | "fennel" | "fish" | "fluent" | "ftl" | "fortran-fixed-form" | "f" | "for" | "f77" | "fortran-free-form" | "f90" | "f95" | "f03" | "f08" | "f18" | "fsharp" | "f#" | "fs" | "gdresource" | "gdscript" | "gdshader" | "genie" | "gherkin" | "git-commit" | "git-rebase" | "gleam" | "glimmer-js" | "gjs" | "glimmer-ts" | "gts" | "glsl" | "gnuplot" | "go" | "graphql" | "gql" | "groovy" | "hack" | "haml" | "handlebars" | "hbs" | "haskell" | "hs" | "haxe" | "hcl" | "hjson" | "hlsl" | "html" | "html-derivative" | "http" | "hurl" | "hxml" | "hy" | "imba" | "ini" | "properties" | "java" | "javascript" | "js" | "cjs" | "mjs" | "jinja" | "jison" | "json" | "json5" | "jsonc" | "jsonl" | "jsonnet" | "jssm" | "fsl" | "jsx" | "julia" | "jl" | "kdl" | "kotlin" | "kt" | "kts" | "kusto" | "kql" | "latex" | "lean" | "lean4" | "less" | "liquid" | "llvm" | "log" | "logo" | "lua" | "luau" | "make" | "makefile" | "markdown" | "md" | "marko" | "matlab" | "mdc" | "mdx" | "mermaid" | "mmd" | "mipsasm" | "mips" | "mojo" | "move" | "narrat" | "nar" | "nextflow" | "nf" | "nginx" | "nim" | "nix" | "nushell" | "nu" | "objective-c" | "objc" | "objective-cpp" | "ocaml" | "openscad" | "scad" | "pascal" | "perl" | "php" | "pkl" | "plsql" | "po" | "pot" | "potx" | "polar" | "postcss" | "powerquery" | "powershell" | "ps" | "ps1" | "prisma" | "prolog" | "proto" | "protobuf" | "pug" | "jade" | "puppet" | "purescript" | "python" | "py" | "qml" | "qmldir" | "qss" | "r" | "racket" | "raku" | "perl6" | "razor" | "reg" | "regexp" | "regex" | "rel" | "riscv" | "rosmsg" | "rst" | "ruby" | "rb" | "rust" | "rs" | "sas" | "sass" | "scala" | "scheme" | "scss" | "sdbl" | "1c-query" | "shaderlab" | "shader" | "shellscript" | "bash" | "sh" | "shell" | "zsh" | "shellsession" | "console" | "smalltalk" | "solidity" | "soy" | "closure-templates" | "sparql" | "splunk" | "spl" | "sql" | "ssh-config" | "stata" | "stylus" | "styl" | "svelte" | "swift" | "system-verilog" | "systemd" | "talonscript" | "talon" | "tasl" | "tcl" | "templ" | "terraform" | "tf" | "tfvars" | "tex" | "toml" | "ts-tags" | "lit" | "tsv" | "tsx" | "turtle" | "twig" | "typescript" | "ts" | "cts" | "mts" | "typespec" | "tsp" | "typst" | "typ" | "v" | "vala" | "vb" | "cmd" | "verilog" | "vhdl" | "viml" | "vim" | "vimscript" | "vue" | "vue-html" | "vue-vine" | "vyper" | "vy" | "wasm" | "wenyan" | "文言" | "wgsl" | "wikitext" | "mediawiki" | "wiki" | "wit" | "wolfram" | "wl" | "xml" | "xsl" | "yaml" | "yml" | "zenscript" | "zig" | — |
Language of the code snippet. | ||
| allowCopy? | boolean | string | — |
Show or hide a persistent button that copies the | ||
| allowErrors? | boolean | string | — |
Whether or not to allow errors when a | ||
| showErrors? | boolean | — |
Show or hide error diagnostics when a | ||
| shouldAnalyze? | boolean | — |
Whether or not to analyze the source code for type errors and provide quick information on hover. | ||
| paddingX? | string | — |
Horizontal padding to apply to the wrapping element. | ||
| paddingY? | string | — |
Vertical padding to apply to the wrapping element. | ||
| css? | CSSObject | — |
CSS styles to apply to the wrapping element. | ||
| className? | string | — |
Class name to apply to the wrapping element. | ||
| style? | React.CSSProperties | — |
Style to apply to the wrapping element. | ||
Renders an inline code element with optional syntax highlighting and copy button.
Properties
CodeInlinePropsReturns
React.JSX.Element | Promise<React.JSX.Element>Modifiers
asyncParses the props of an MDX code element for passing to CodeInline.
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| props | React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> | — |
Returns
| Property | Type | |
|---|---|---|
| children | string | |
| language? | "abap" | "actionscript-3" | "ada" | "angular-html" | "angular-ts" | "apache" | "apex" | "apl" | "applescript" | "ara" | "asciidoc" | "adoc" | "asm" | "astro" | "awk" | "ballerina" | "bat" | "batch" | "beancount" | "berry" | "be" | "bibtex" | "bicep" | "blade" | "bsl" | "1c" | "c" | "cadence" | "cdc" | "cairo" | "clarity" | "clojure" | "clj" | "cmake" | "cobol" | "codeowners" | "codeql" | "ql" | "coffee" | "coffeescript" | "common-lisp" | "lisp" | "coq" | "cpp" | "c++" | "crystal" | "csharp" | "c#" | "cs" | "css" | "csv" | "cue" | "cypher" | "cql" | "d" | "dart" | "dax" | "desktop" | "diff" | "docker" | "dockerfile" | "dotenv" | "dream-maker" | "edge" | "elixir" | "elm" | "emacs-lisp" | "elisp" | "erb" | "erlang" | "erl" | "fennel" | "fish" | "fluent" | "ftl" | "fortran-fixed-form" | "f" | "for" | "f77" | "fortran-free-form" | "f90" | "f95" | "f03" | "f08" | "f18" | "fsharp" | "f#" | "fs" | "gdresource" | "gdscript" | "gdshader" | "genie" | "gherkin" | "git-commit" | "git-rebase" | "gleam" | "glimmer-js" | "gjs" | "glimmer-ts" | "gts" | "glsl" | "gnuplot" | "go" | "graphql" | "gql" | "groovy" | "hack" | "haml" | "handlebars" | "hbs" | "haskell" | "hs" | "haxe" | "hcl" | "hjson" | "hlsl" | "html" | "html-derivative" | "http" | "hurl" | "hxml" | "hy" | "imba" | "ini" | "properties" | "java" | "javascript" | "js" | "cjs" | "mjs" | "jinja" | "jison" | "json" | "json5" | "jsonc" | "jsonl" | "jsonnet" | "jssm" | "fsl" | "jsx" | "julia" | "jl" | "kdl" | "kotlin" | "kt" | "kts" | "kusto" | "kql" | "latex" | "lean" | "lean4" | "less" | "liquid" | "llvm" | "log" | "logo" | "lua" | "luau" | "make" | "makefile" | "markdown" | "md" | "marko" | "matlab" | "mdc" | "mdx" | "mermaid" | "mmd" | "mipsasm" | "mips" | "mojo" | "move" | "narrat" | "nar" | "nextflow" | "nf" | "nginx" | "nim" | "nix" | "nushell" | "nu" | "objective-c" | "objc" | "objective-cpp" | "ocaml" | "openscad" | "scad" | "pascal" | "perl" | "php" | "pkl" | "plsql" | "po" | "pot" | "potx" | "polar" | "postcss" | "powerquery" | "powershell" | "ps" | "ps1" | "prisma" | "prolog" | "proto" | "protobuf" | "pug" | "jade" | "puppet" | "purescript" | "python" | "py" | "qml" | "qmldir" | "qss" | "r" | "racket" | "raku" | "perl6" | "razor" | "reg" | "regexp" | "regex" | "rel" | "riscv" | "rosmsg" | "rst" | "ruby" | "rb" | "rust" | "rs" | "sas" | "sass" | "scala" | "scheme" | "scss" | "sdbl" | "1c-query" | "shaderlab" | "shader" | "shellscript" | "bash" | "sh" | "shell" | "zsh" | "shellsession" | "console" | "smalltalk" | "solidity" | "soy" | "closure-templates" | "sparql" | "splunk" | "spl" | "sql" | "ssh-config" | "stata" | "stylus" | "styl" | "svelte" | "swift" | "system-verilog" | "systemd" | "talonscript" | "talon" | "tasl" | "tcl" | "templ" | "terraform" | "tf" | "tfvars" | "tex" | "toml" | "ts-tags" | "lit" | "tsv" | "tsx" | "turtle" | "twig" | "typescript" | "ts" | "cts" | "mts" | "typespec" | "tsp" | "typst" | "typ" | "v" | "vala" | "vb" | "cmd" | "verilog" | "vhdl" | "viml" | "vim" | "vimscript" | "vue" | "vue-html" | "vue-vine" | "vyper" | "vy" | "wasm" | "wenyan" | "文言" | "wgsl" | "wikitext" | "mediawiki" | "wiki" | "wit" | "wolfram" | "wl" | "xml" | "xsl" | "yaml" | "yml" | "zenscript" | "zig" | |
| Intersects | ||
|---|---|---|
Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "children" | "style" | "className"> | ||