Is there any component suitable to display code snippets

  • Goal: I'm trying to display a box with a code snippet inside, maybe with a copy button on the top right corner if i wanted to be fancypants

  • Steps: I've tried to use md containers, html, and other options to no avail, and would like to get inputs from the community before lowering my expectations or going knee deep into making a custom component.

Thanks everyone,
Tom

How about a form?

Standard text boxes or the rich text editor support markdown, so you can put ``` before and after the code snippet to get it to format as code.

Substring the snippet into a text box in the form with componentName.value.substring(text1.value.indexOf("```")) (or just setValue the snippet from wherever it is coming from).

Then set the "submit" action for the form to execute utils.copyToClipboard(form1.data) and it pastes the snippet to the clipboard:

3 Likes

That's absolutely what i was looking for !