Example of Adornments in ASP.NET MVC TextArea Control
This example demonstrates the adornments enhance a textarea with prefix/suffix elements, icons, text, or buttons that provide context or quick actions. Flow and orientation can be configured for horizontal or vertical layouts.
Flow Direction
Orientation Direction
@Html.UiTextArea("icontemplate", null, new UiTextAreaOptions { Label = "Add a comment", FloatLabelType = UiFloatLabelType.Auto, CssClass = "ui-input-outlined", Rows = 5, ResizeMode = UiResizeMode.None, PrependTemplate = "#taStart", AppendTemplate = "#taEnd" })
@Html.UiDropDownList("flow-orientation", new UiDropDownListOptions { Width = "130px", Value = "Horizontal", OnChange = "onFlowChange", Items = ((string[])ViewData["orientationData"]).Select(o => new UiListItem(o, o)).ToList() })
@Html.UiDropDownList("orient-orientation", new UiDropDownListOptions { Width = "130px", Value = "Horizontal", OnChange = "onOrientChange", Items = ((string[])ViewData["orientationData"]).Select(o => new UiListItem(o, o)).ToList() })
<style>
.content-wrapper { width: 90%; margin: 0 auto; min-width: 185px; }
.content-wrapper .ta-row { padding: 12px 0; }
.content-wrapper .ta-cols { display: flex; gap: 24px; }
.content-wrapper .ta-cols > * { flex: 1 1 0; min-width: 0; }
.content-wrapper .ta-title { padding: 15px 0 0; font-weight: 700; }
.property-section .property-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.property-section .prop-input { width: 130px; padding: 4px 6px; border: 1px solid var(--ui-input-border); border-radius: var(--ui-radius); background: var(--ui-surface); color: var(--ui-text); font: inherit; }
.ador-textarea .ta-row { padding: 40px 0 0; }
.ador-textarea .e-icons { cursor: pointer; }
.ta-flow-vertical { flex-direction: column; align-items: stretch; }
.ta-flow-vertical .ui-input-separator { display: none; }
.ta-orient-vertical .ui-input-prepend, .ta-orient-vertical .ui-input-append { flex-direction: column; align-items: center; }
</style>
<template id="taStart"><span class="e-icons e-bold"></span><span class="ui-input-separator"></span><span class="e-icons e-italic"></span><span class="ui-input-separator"></span></template>
<template id="taEnd"><span class="ui-input-separator"></span><span class="e-icons e-save"></span><span class="ui-input-separator"></span><span class="e-icons e-trash"></span><span class="ui-input-separator"></span></template>
<div class="control-section multiline">
<div class="content-wrapper ador-textarea">
<div class="ta-row">
@Html.UiTextArea("icontemplate", null, new UiTextAreaOptions { Label = "Add a comment", FloatLabelType = UiFloatLabelType.Auto, CssClass = "ui-input-outlined", Rows = 5, ResizeMode = UiResizeMode.None, PrependTemplate = "#taStart", AppendTemplate = "#taEnd" })
</div>
</div>
</div>
<div class="demo-property-panel property-section" title="Properties">
<div class="property-row"><span>Flow Direction</span> @Html.UiDropDownList("flow-orientation", new UiDropDownListOptions { Width = "130px", Value = "Horizontal", OnChange = "onFlowChange", Items = ((string[])ViewData["orientationData"]).Select(o => new UiListItem(o, o)).ToList() })</div>
<div class="property-row"><span>Orientation Direction</span> @Html.UiDropDownList("orient-orientation", new UiDropDownListOptions { Width = "130px", Value = "Horizontal", OnChange = "onOrientChange", Items = ((string[])ViewData["orientationData"]).Select(o => new UiListItem(o, o)).ToList() })</div>
</div>
<script>
// Syncfusion: the flow puts the adornments beside the text (Horizontal) or above and below it (Vertical); the orientation lays the icons of an adornment in a row or in a column
function group() { return document.getElementById('icontemplate').closest('.ui-input-group'); }
function onFlowChange(value) { if (value) { group().classList.toggle('ta-flow-vertical', value === 'Vertical'); } }
function onOrientChange(value) { if (value) { group().classList.toggle('ta-orient-vertical', value === 'Vertical'); } }
// the trash icon clears the comment
document.addEventListener('click', function (e) {
var icon = e.target.closest ? e.target.closest('.e-trash') : null;
var box = document.getElementById('icontemplate');
if (!icon || !box || !box.closest('.ui-input-group').contains(icon)) { return; }
box.value = '';
box.dispatchEvent(new Event('input', { bubbles: true }));
box.focus();
});
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class TextAreaController : Controller
{
// The page is Views/TextArea/Adornments.cshtml; it draws what ViewData holds.
public ActionResult Adornments()
{
ViewData["orientationData"] = new string[] { "Horizontal", "Vertical" };
return View();
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
This sample showcases TextArea adornments using prependTemplate and appendTemplate to add bold/italic (prefix) and save/delete (suffix) icons. A DropDownList allows you to switch adornmentFlow and adornmentOrientation between Horizontal and Vertical, and the layout updates dynamically via dataBind whenever the selected option changes.