Code Block¶
A monospace code editor textarea, or a read only block for a preview.
Decision¶
| When | Use |
|---|---|
| JSON, templates, and scripts the user edits | The Code Block textarea |
| A short value | Copy Field or the mono class from Utility Classes |
Usage¶
<textarea class="stolon-code" id="txtTemplate"></textarea>
<pre class="stolon-code stolon-code-block">{ "event": "Approved" }</pre>
<pre class="stolon-code stolon-code-block stolon-code-invalid">{ not json }</pre>
Classes: stolon-code, stolon-code-block, stolon-code-invalid.
States and Modifiers¶
stolon-codeis a full width mono textarea on the field surface in the theme text color, at least 240px tall, that keeps its lines unwrapped and resizes vertically.stolon-code-blockgoes withstolon-code. It is as tall as its text and wraps.stolon-code-invalidgoes withstolon-codeand turns the border to--stolon-error. Toggle it from your own validation.
Reference¶
Generated from the code by scripts/build-docs.mjs. Edit the code, not this section.
| Class | What it looks like |
|---|---|
stolon-code |
Full width monospace textarea for editing code |
stolon-code.stolon-code-block |
Read only block of code or JSON that wraps and is only as tall as its text |
stolon-code.stolon-code-invalid |
Code field or block with a red border for content that is not valid |
Example¶
Example Code¶
<!-- title: Code Block -->
<textarea class="stolon-code" id="txtTemplate" rows="4" spellcheck="false">{
"event": "Approved",
"user": "viewer"
}</textarea>
<pre class="stolon-code stolon-code-block">{ "event": "Approved", "title": "A long title that wraps instead of scrolling sideways" }</pre>
<pre class="stolon-code stolon-code-block stolon-code-invalid">{ "event": </pre>