Skip to content

Text Area Examples

The examples below assume that you have imported the component and set up the theme.

Basic

Add a multi-line text field to a form. name submits the text with the form, and a <label for> names the field.

--empty
Size
2
Works only with resize="auto"
6
Indicators
Clear button
An SVG in the clear-icon slot.
Slots
A note icon in the before slot.
A send button in the after slot.
State
<form class="text-area-basic">
<label for="text-area-notes">Notes</label>
<sv-text-area
id="text-area-notes"
name="notes"
placeholder="Anything we should know?"
></sv-text-area>
</form>
<style>
.text-area-basic {
display: grid;
gap: 0.5em;
place-items: center;
label {
font-weight: 600;
}
.clear-icon,
.note-icon {
inline-size: 1.25em;
fill: none;
stroke: currentcolor;
stroke-width: 2;
stroke-linecap: round;
}
.note-icon {
block-size: 1lh;
}
.send-button {
display: grid;
place-items: center;
inline-size: 1lh;
block-size: 1lh;
padding: 0;
font: inherit;
color: var(--sv-accent);
cursor: pointer;
background: none;
border: none;
border-radius: 50%;
transition: background-color 150ms;
&:hover,
&:active {
background-color: var(--sv-gray-5);
}
svg {
inline-size: 1.25em;
fill: currentcolor;
}
}
}
</style>