Theme

Selective component imports

API reference: <cad-code-block>

codecodestring''copyablecopyablebooleanfalsecopy-labelcopyLabelstring'Copy'copied-labelcopiedLabelstring'Copied'copy-error-labelcopyErrorLabelstring'Copy failed'filenamefilenamestring''languagelanguagestring''show-line-numbersshowLineNumbersbooleanfalsetonetoneCadCodeBlockTone'accent'codestringcodenocopyablebooleancopyableyescopyLabelstringcopy-labelnocopiedLabelstringcopied-labelnocopyErrorLabelstringcopy-error-labelnofilenamestringfilenamenolanguagestringlanguagenoshowLineNumbersbooleanshow-line-numbersyestoneCadCodeBlockTonetoneyescad-code-copyCustomEventReports whether the source was copied to the clipboard.(default)Progressive code content used when `code` is not set.actionsOptional actions such as an application-owned copy button.copyOptional compact copy button.baseNative figure.codeNative code element.headerFilename and language metadata.preNative preformatted block.--cad-code-bgCode surface color.--cad-code-inkCode foreground color.--cad-code-commentSyntax comment color.--cad-code-keywordSyntax keyword color.--cad-code-stringSyntax string color.--cad-code-numberSyntax number color.--cad-code-tagSyntax tag color.--cad-code-attributeSyntax attribute color.--cad-code-propertySyntax property color.--cad-code-punctuationSyntax punctuation color.

Copying

Add copyable for the built-in copy button. cad-code-copy reports success or failure. Use the actions slot for custom controls.

Syntax colors

HTML, Astro, JavaScript, TypeScript, CSS, JSON, and shell have built-in syntax colors. Other languages display as plain text. For a different highlighter, place pre-highlighted markup in the default slot.

Back to top