Skip to main content

Textbox

The Textbox widget is a single line text entry widget. A fairly large set of key bindings are supported by default. If the entered text is longer than the allocation of the widget, the widget will scroll so that the cursor position is visible.

Properties

The Textbox widget inherits from Widget class → Has all Widget properties.
  • inputType: InputTypes → The type of the textbox.
  • title: string → The label of the textbox.
  • input: Widget → The input widget of the textbox.
  • label: Label → The label widget that contain the title of the textbox.

Constructor

ParameterTypeRequiredDescription
idstringyesThe id of the widget
parentWidgetnoThe parent of the widget. Default is null
src/main.ts
import { Textbox } from "@cedro/ui";

const myTextbox: Textbox = new Textbox("my-txt");

myTextbox.setInputType("text");
myTextbox.setValue("Hello world!");
myTextbox.setTitle("Cedro");

Public Methods

setInputType

Set the input type of the widget. Can be text, date, datetime-local, file, number, password, email, url, color or tel".

Parameters

ParameterTypeRequiredDescription
typeInputTypesyesThe type.

Returns Value

void

Example

src/main.ts
myTextbox.setInputType("text");

setValue

Set the value of the input.

Parameters

ParameterTypeRequiredDescription
valuestringyesThe value.

Returns Value

void

Example

src/main.ts
myTextbox.setValue("Hello world!");

setTitle

Set the title of the input label.

Parameters

ParameterTypeRequiredDescription
titlestringyesThe title of the label.

Returns Value

void

Example

src/main.ts
myTextbox.setTitle("Cedro");

////////////////////////////////////////////////////////////////

getInputType

Get the input type of the widget. Can be text, date, datetime-local, file, number, password, email, url, color or tel".

Parameters

void

Returns Value

InputTypes

Example

src/main.ts
const type: InputTypes = myTextbox.getInputType();

getValue

Get the value of the input.

Parameters

void

Returns Value

string

Example

src/main.ts
const value = myTextbox.getValue();

getTitle

Get the title of the input label.

Parameters

void

Returns Value

string

Example

src/main.ts
const title = myTextbox.getTitle();