children (Required) | string | This is the code snippet that will be rendered in the code block. | '' |
language (Required) | 'javascript' , 'typescript' , 'cs' , 'csharp' , 'cpp' , 'go' , 'http' ,'java' , 'perl' , 'php' , 'python' , 'ruby' , 'scala' , 'swift' , 'kotlin' ,'objectivec' , 'dart' , 'bash' , 'shell' , 'sql' , 'yaml' , 'json' , 'diff' , 'xml' , 'none' | The language to highlight the code block as. When set to 'none' , no syntax highlighting will be applied. | |
darkMode | boolean | Determines whether or not the component will appear in dark mode. | false |
className | string | Applies a className to the root element's classList. | |
showLineNumbers | boolean | Shows line numbers next to each line of code in the passed code snippet. NOTE: While you can set this to true regardless of the code component being multiline, the line numbers will not be displayed if the multiline prop is true . | false |
lineNumberStart | number | Specifies the number by which to start line numbering. | 1 |
showWindowChrome | boolean | Shows a stylized window chrome frame around the code snippet. This is purely stylistic. | false |
chromeTitle | string | Shows a filename-like title in the window chrome frame.NOTE: While you can set this prop if showWindowChrome is false , it will not be displayed unless the showWindowChrome prop is true . | '' |
showCustomActionButtons | boolean | Shows custom action buttons in the panel if set to true and there is at least one item in customActionButtons | false |
customActionButtons | Array<React.ReactElement> | An array of custom action buttons using the IconButton component. For example: [<IconButton><Icon glyph="Cloud" /></IconButton>, <IconButton><Icon glyph="Code" /></IconButton>] | [] |
onCopy | Function | Callback fired when Code is copied | |
copyable | boolean | When true, allows the code block to be copied to the user's clipboard | true |
highlightLines | Array<number | [number, number]> | An optional array of lines to highlight. The array can only contain numbers corresponding to the line numbers to highlight, and / or tuples representing a range (e.g. [6, 10] ); | |
languageOptions | Array<LanguageOption> (see below) | An array of language options. When provided, a LanguageSwitcher dropdown is rendered. | |
onChange | (language: LanguageOption) => void | A change handler triggered when the language is changed. Invalid when no languageOptions are provided | |
usePortal | boolean | Will position the language switcher dropdown relative to its parent without using a Portal if usePortal is set to false. | true |
portalContainer | HTMLElement | null | Sets the container used for the language switcher's dropdown's portal. | |
scrollContainer | HTMLElement | null | If the language switcher's dropdown's portal has a scrollable ancestor other than the window, this prop allows passing a reference to that element to allow the portal to position properly. | |
portalClassName | string | Passes the given className to the language switcher's dropdown's portal container if the default portal container is being used. | |
popoverZIndex | number | Sets the z-index CSS property for the language switcher's dropdown. | |