Composer
ds-composer supplies the shared face, row-grid sizing and highlight layer for
an editable message. Its direct child is a native textarea, so labels, forms,
validation, selection and ARIA references to a mention list stay native.
<ds-composer auto-grow max-rows="12" variant="plain"> <textarea rows="2" aria-label="Comment" aria-controls="people"></textarea></ds-composer>Set highlights to UTF-16 ranges: [{ start: 3, end: 7, color: "var(--ds-sharp-blue)" }].
Omit color for the shared accent. DS1 mixes the supplied hue with the surface
ink so pale identity colours remain legible. Invalid and overlapping ranges are ignored.
To show the colour itself, add fill: true: the colour lies behind the words,
which keep the text colour, at half strength on light paper and under a third on
dark. Every palette colour keeps the words at 4.5:1 or more, and a pale accent
still shows. Use it for the accent on a change or a colour value in code;
keep the tint for names in a message.
composer.highlights = [ { start: 0, end: 7, color: "#594dff", fill: true }, { start: 12, end: 27, fill: true }, // the accent];The layer renders the exact original text; it never inserts avatars, padding or extra characters that would separate highlights from the native caret. Mention matching, candidates and submission remain product data and actions.
Use field for a standalone field or plain inside a composed surface.
Native rows sets the minimum. auto-grow grows on the row grid up to
max-rows; additional content scrolls. Width, fonts and surface scale changes
reflow both layers. Without automatic growth, the field can be resized vertically.
wrap="off" preserves horizontal scrolling. Forced-colour mode uses native text.
Classes and style place the host in the page; do not restyle the child.
Native form reset is kept.
Call the host’s refresh() after assigning a native value
programmatically. User input and form reset refresh automatically. The mirror
is hidden from assistive technology, and contains no interactive elements.
Use ds-input multiline for ordinary multiline fields that do not need highlights or
a light-DOM connection to external options.
Design examples
Section titled “Design examples”The plain composer grows in whole lines as you write.
<section class="specimen">
<ds-composer auto-grow max-rows="6" variant="plain"><textarea rows="3" aria-label="Photograph caption">A north-facing window, just before the first visitors arrive.</textarea></ds-composer>
</section>
<style>
.specimen { width: 100%; min-width: 0; --cell: calc(20px * var(--sf, 1)); }
.specimen .line { width: 100%; }
.specimen .grow { flex: 1; min-width: 0; }
.specimen .muted { color: var(--ds-text-color-muted); }
.specimen .mono { --ds-typeface-regular: var(--ds-typeface-mono); font-variant-numeric: tabular-nums; }
.specimen .value { width: calc(4 * var(--cell)); text-align: right; }
.specimen .mark { display: inline-flex; align-items: flex-end; width: var(--cell); height: var(--ds-control-height); flex: 0 0 var(--cell); }
.specimen .columns { display: flex; flex-wrap: wrap; gap: var(--cell); }
.specimen .columns > * { min-width: 0; }
.specimen fieldset { border: 0; padding: 0; margin: 0; }
.specimen legend { padding: 0; }
.specimen label { display: flex; align-items: flex-end; gap: calc(var(--cell) / 2); min-height: var(--cell); }
.specimen ds-panel { height: calc(10 * var(--cell)); }
</style>