Welcome to Vanilla Breeze
This bell pulls live notifications from /go/notify/messages — the same contract documented at /docs/concepts/service-contracts/. Static articles like this one are the no-JS / no-backend fallback.
This bell pulls live notifications from /go/notify/messages — the same contract documented at /docs/concepts/service-contracts/. Static articles like this one are the no-JS / no-backend fallback.
Form-associated comment form composing
<comment-box> is a small form-associated primitive that wraps <markdown-editor> with the canonical Submit / Cancel button row. It's used standalone for top-level comment forms or as the reply-form template inside a <comment-thread>.
The component is presentational with respect to persistence. The submit event is cancellable: on success the value is cleared automatically, but if the author preventDefault()s (e.g., the network call fails), the value is preserved.
| Use this | When |
|---|---|
<comment-box> | You want a standalone comment / reply form with Submit + Cancel and form participation. |
<markdown-editor> | You just want the editor — no Submit/Cancel chrome, no form participation. |
<form-field> | Generic input wrapper. Doesn't know about markdown. |
<chat-input> | Single-line chat input with send. Different shape from a paragraph comment. |
<comment-box name="comment" placeholder="Add a comment…"></comment-box>
The component auto-creates the inner <markdown-editor> + <textarea> for you. If you need pre-existing markdown content, use the value attribute or provide your own <markdown-editor> child explicitly.
Pre-fill via value and add the Cancel button via data-show-cancel. Customize the Submit label.
<comment-box value="…existing comment text…" submit-label="Save" data-show-cancel></comment-box>
Children with slot="toolbar" are moved into the toolbar row, on the left of the Submit / Cancel buttons.
<comment-box> <button slot="toolbar" type="button" aria-label="Attach file">📎</button> <button slot="toolbar" type="button" aria-label="Mention">@</button></comment-box>
The toolbar has role="toolbar". You wire the click handlers; the comment-box doesn't interpret them.
Set data-min-length and / or data-max-length. When data-max-length is set, a live counter is rendered next to the buttons.
<comment-box data-min-length="3" data-max-length="280" placeholder="Up to 280 chars…"></comment-box>
The component is form-associated via ElementInternals. Drop it inside any <form> with name set, and the markdown source submits like any other field.
<form action="/comments" method="post"> <comment-box name="body" required placeholder="Comment…"></comment-box> <button type="submit">Submit</button></form>
The comment-box:submit event is cancellable. If you call preventDefault(), the value is preserved (useful when your network call fails and you want the user to retry without re-typing).
box.addEventListener('comment-box:submit', async (e) => { const { value } = e.detail; try { await api.postComment(value); // Default: value clears automatically } catch (err) { e.preventDefault(); // keep the value so the user can retry showToast('Failed — please try again'); }});
| Key | Action |
|---|---|
| Cmd/Ctrl + Enter | Submit (matches GitHub / Slack convention). |
| Tab | Move from editor to toolbar buttons to Submit / Cancel. |
| Attribute | Type | Default | Description |
|---|---|---|---|
name | string | — | Form field name. |
value | string | — | Pre-filled markdown content (e.g. for edit mode). |
placeholder | string | — | Editor placeholder text. |
submit-label | string | Comment | Submit button label. |
cancel-label | string | Cancel | Cancel button label. |
data-show-cancel | boolean | false | Render the Cancel button. |
data-min-length | number | — | Validation: minimum character length. |
data-max-length | number | — | Validation: maximum character length; also shows a live counter. |
required | boolean | false | Marks the field required for form validation. |
disabled | boolean | false | Disables the editor and buttons. |
| Event | Bubbles | Detail |
|---|---|---|
comment-box:submit | yes (cancellable) | { value } |
comment-box:cancel | yes | { value } |
comment-box:input | yes | { value, length } |
| Member | Description |
|---|---|
value | Get / set the current markdown content. |
clear() | Clear the value and emit comment-box:input. |
focus() | Focus the inner editor. |
form / validity / checkValidity() | Standard form-associated members. |
<markdown-editor> — the input the form composes.<comment-thread> — the threaded-discussion container that uses this as its reply-form template.<reaction-bar> — per-comment emoji reactions.