Getting Started with MultilineTextBox Web Component

Smart UI Web Components work with current evergreen browsers and Node 18+ for local tooling; pin package versions to match your project policy.

Smart UI is distributed as the smart-webcomponents NPM package. You can also use the full download from the Download page.

Quick start

  1. Install the package:

    npm install smart-webcomponents

  2. Load the MultilineTextBox module (ES module script):

    <script type="module" src="node_modules/smart-webcomponents/source/modules/smart.multilinetextbox.js"></script>

  3. Add the default stylesheet (prefer angular.json / bundler entry in app codebases; for plain HTML use a link):

    <link rel="stylesheet" type="text/css" href="node_modules/smart-webcomponents/source/styles/smart.default.css" />

  4. Add markup in one of two ways - semantic custom element (the component tag is in your HTML) or a host div (you mount programmatically with appendTo):

    Semantic element (id matches the selector in Smart()):

    <smart-multiline-text-box id="multilinetextbox"></smart-multiline-text-box>

    Host container (id matches appendTo on Smart.MultilineTextBox):

    <div id="multilinetextboxContainer"></div>

  5. Initialize after the module loads: define a const multilinetextboxOptions object, then either bind with Smart('#multilinetextbox', ...) on the semantic tag or use new Smart.MultilineTextBox({ ...multilinetextboxOptions, appendTo: '#multilinetextboxContainer' }) on the host div:

    <script type="module">
    	import 'node_modules/smart-webcomponents/source/modules/smart.multilinetextbox.js';
    
    	const multilinetextboxOptions = { value: "Peter Brown" };
    
    	// Option A - semantic <smart-multiline-text-box> with id="multilinetextbox"
    	Smart('#multilinetextbox', class {
    		get properties() {
    			return multilinetextboxOptions;
    		}
    	});
    
    	// Option B - host div id="multilinetextboxContainer"
    	// const multilinetextboxInstance = new Smart.MultilineTextBox({
    	// 	...multilinetextboxOptions,
    	// 	appendTo: '#multilinetextboxContainer'
    	// });
    
    	// Option C - constructor(selector, options), then append the returned element yourself
    	// const myMultilineTextBox = new Smart.MultilineTextBox('#multilinetextbox', multilinetextboxOptions);
    	// document.body.appendChild(myMultilineTextBox);
    </script>
    		

    Uncomment Option B when you use the host div; use Option A when you use the semantic element. The Runtime cookbook also documents new Smart.MultilineTextBox('#multilinetextbox', multilinetextboxOptions) with appendChild, and document.createElement('smart-multiline-text-box') with .props or Object.assign (all are valid patterns; do not combine overlapping patterns for the same instance unless you intend multiple components).

  6. Serve the folder over HTTP (or use your bundler dev server) and open the page.

Runtime cookbook

Alternative creation patterns and imperative APIs. These are all valid ways to create Smart UI components: semantic markup + Smart(); new Smart.MultilineTextBox({ ...options, appendTo: '#...' }); new Smart.MultilineTextBox('#multilinetextbox', multilinetextboxOptions) plus appendChild on the returned element; and document.createElement('smart-multiline-text-box') then assigning options via .props or Object.assign on the element.

Constructor with a selector string and options, then append the returned element (for example const myMultilineTextBox = new Smart.MultilineTextBox('#multilinetextbox', multilinetextboxOptions)):

	const multilinetextboxOptions = { value: "Peter Brown" };
	const myMultilineTextBox = new Smart.MultilineTextBox('#multilinetextbox', multilinetextboxOptions);
	document.body.appendChild(myMultilineTextBox);
	

Create with document.createElement('smart-multiline-text-box'), assign properties (same as any custom element), then append:

	const multilinetextboxOptions = { value: "Peter Brown" };
	const multilinetextbox = document.createElement('smart-multiline-text-box');
	Object.assign(multilinetextbox, multilinetextboxOptions);
	document.body.appendChild(multilinetextbox);
	

Host on a div with appendTo (import the module, then instantiate when the document is ready; the container id must match appendTo):

	import "../../source/modules/smart.multilinetextbox.js";

	document.readyState === 'complete' ? init() : window.addEventListener('load', init);

	function init() {
		const multilinetextboxOptions = { value: "Peter Brown" };
		const multilinetextbox = new Smart.MultilineTextBox({
			...multilinetextboxOptions,
			appendTo: '#multilinetextboxContainer'
		});
	}
	

Append to the DOM:

const container = document.getElementById('multilinetextbox-container');
container.appendChild(multilinetextbox);
	

Remove from the DOM:

multilinetextbox.remove();
	

Set a property:

multilinetextbox.disabled = true;
multilinetextbox.theme = 'dark';
	

Get a property value:

const isDisabled = multilinetextbox.disabled;
const currentTheme = multilinetextbox.theme;
	

Invoke a method:

multilinetextbox.refresh();
multilinetextbox.focus();
	

Add event listener:

multilinetextbox.addEventListener('change', (event) => {
    console.log('change triggered:', event.detail.oldValue);
});
	

Remove event listener:

const handleMultilineTextBoxEvent = (event) => {
    console.log('change triggered:', event.detail.oldValue);
};

multilinetextbox.addEventListener('change', handleMultilineTextBoxEvent);
multilinetextbox.removeEventListener('change', handleMultilineTextBoxEvent);
	

Accessibility

The MultilineTextBox component follows WAI-ARIA best practices:

  • Keyboard navigation - Tab, Arrow keys, Enter, and Escape are supported
  • ARIA roles - Appropriate roles and labels are applied automatically
  • Focus management - Visible focus indicators for keyboard users
  • Screen readers - State changes are announced to assistive technology
  • High contrast - Supports Windows High Contrast Mode and forced colors

For custom labeling, set aria-label or aria-labelledby attributes on the component.

Live demos

Supported stacks: Smart UI targets Angular 17+, React 18+, Vue 3+, Node 18 LTS, and evergreen browsers; pin exact package versions to your org policy.