Code
A component designed to display code snippets in a readable format, often with syntax highlighting for better readability.
A component designed to display code snippets in a readable format, often with syntax highlighting for better readability.
Basic usage example to quickly see how the Code
works.
React.createElement()
{
"filePath": "C:/Data/path/package.json",
"error": {
"errno": -4048,
"code": "EPERM",
"syscall": "open",
"path": "C:\Data\path\package.json"
},
"_tag": "fs.WriteFileError"
}
{
"name": "string",
"symbol": "string",
"position": "number",
"mass": "number"
}
Interactive configurator to explore customization options for the Code
component.
{
"filePath": "C:/Data/path/package.json",
"error": {
"errno": -4048,
"code": "EPERM",
"syscall": "open",
"path": "C:\Data\path\package.json"
},
"_tag": "fs.WriteFileError"
}
{
"name": "string",
"symbol": "string",
"position": "number",
"mass": "number"
}
type T = "code" | "samp";
Styles API | Type | Default | Annotation |
---|---|---|---|
unstyled? | Partial<Record<T, boolean>> | false | if true , default styles will be removed |
className? | string | undefined | pass to root component <div> |
classNames? | Partial<Record<T, string>> | undefined | |
style? | CSSProperties | undefined | pass to root component <div> |
styles? | Partial<Record<T, CSSProperties>> | undefined |
type Dir = "ltr" | "rtl" | (string & {});
Props API | Type | Default | Annotation |
---|---|---|---|
children? | string | undefined | Only accept children as strings |
block? | boolean | false | If set code will be rendered inside pre |
quote? | boolean | false | Allows applying styles like as blockquote |
dir? | Dir | rtl | Attribute that indicates the directionality of the element's text |
code? | string | undefined | Used to display inline code |
samp? | Record<string, any> | undefined | Used to display data type conversions to strings such as JSON. |
Full working code example, including necessary markup and styles. You can copy and paste this code directly to start using the component immediately.