Input
The TkInput component is used to capture text input from the user.
- React
- Vue
- Angular
import { TkInput } from '@takeoff-ui/react'
import { TkInput } from '@takeoff-ui/vue'
import { TkInput } from '@takeoff-ui/angular'
Basic​
A simple TkInput display.
- React
- Vue
- Angular
<TkInput
label="Text Input"
mode="text"
hint="Hint text"
placeholder="Placeholder text"
value={value}
onTkChange={(e) => setValue(e.detail)}
/>
<TkInput
label="Text Input"
mode="text"
hint="Hint text"
placeholder="Placeholder text"
/>
Password​
The input field is visually masked to securely hide the characters entered, providing a standard password entry experience.
- React
- Vue
- Angular
<TkInput
label="Password Input"
mode="password"
value={value}
onTkChange={(e) => setValue(e.detail)}
/>
<TkInput
label="Password Input With Status Bar"
mode="password"
showSafetyStatus
value={value1}
onTkChange={(e) => setValue1(e.detail)}
/>
<TkInput
label="Password Input"
mode="password"
v-model="value"
/>
<TkInput
label="Password Input With Status Bar"
mode="password"
showSafetyStatus
v-model="value1"
/>
Counter​
This input field includes a counter feature that allows users to increment or decrement numerical values. The + and - buttons inside the input let users easily adjust the value.
- React
- Vue
- Angular
<TkInput
label="Counter Input"
mode="counter"
value={value}
onTkChange={(e) => setValue(e.detail)}
/>
<TkInput label="Counter Input" mode="counter" v-model="value" />
Mask​
The maskOptions prop is used to define masking configurations supported by the Cleave.js library. With this prop, you can specify any masking options described in the Cleave.js documentation (https://nosir.github.io/cleave.js/). For example, you can configure it for formatting dates, phone numbers, or credit card numbers as needed.
- React
- Vue
- Angular
<TkInput
label="Date Mask"
placeholder="dd.mm.YYYY"
maskOptions={{
date: true,
delimiter: ".",
datePattern: ["d", "m", "Y"],
}}
value={value}
onTkChange={(e) => setValue(e.detail)}
/>
<TkInput
label="Expire Date"
placeholder="mm/yy"
maskOptions={{
date: true,
datePattern: ["m", "y"],
}}
value={value1}
onTkChange={(e) => setValue1(e.detail)}
/>
<TkInput
label="Time Formatting"
placeholder="hh:mm"
maskOptions={{
time: true,
timePattern: ["h", "m"],
}}
value={value2}
onTkChange={(e) => setValue2(e.detail)}
/>
<TkInput
label="Credit Card"
placeholder="hh:mm"
maskOptions={{
blocks: [4, 4, 4, 4],
numericOnly: true,
}}
value={value3}
onTkChange={(e) => setValue3(e.detail)}
/>
<TkInput
label="Letter Only"
placeholder="xxxxxxxxxx"
maskOptions={{
blocks: [40],
letterOnly: true,
}}
value={value4}
onTkChange={(e) => {
setValue4(e.detail);
}}
/>
<script setup>
import { TkInput } from '@takeoff-ui/vue';
const value = ref();
const value1 = ref();
const value2 = ref();
const value3 = ref();
const value4 = ref();
</script>
<template>
<div>
<TkInput
label="Date Mask"
placeholder="dd.mm.YYYY"
:maskOptions.prop="{
date: true,
delimiter: '.',
datePattern: ['d', 'm', 'Y'],
}"
v-model="value"
/>
<TkInput
label="Expire Date"
placeholder="mm/yy"
:maskOptions.prop="{
date: true,
datePattern: ['m', 'y'],
}"
v-model="value1"
/>
<TkInput
label="Time Formatting"
placeholder="hh:mm"
:maskOptions.prop="{
time: true,
timePattern: ['h', 'm'],
}"
v-model="value2"
/>
<TkInput
label="Credit Card"
placeholder="xxxx xxxx xxxx xxxx"
:maskOptions.prop="{
blocks: [4, 4, 4, 4],
numericOnly: true,
}"
v-model="value3"
/>
<TkInput
label="Letter Only"
placeholder="xxxxxxxxxx"
:maskOptions.prop="{
blocks: [40],
letterOnly: true,
}"
v-model="value4"
/>
</div>
</template>
Size​
The "size" prop can be used with one of the sizes "small", "base", and "large". The default value is "base".
- React
- Vue
- Angular
<TkInput
label="Small Input"
size="small"
value={value}
onTkChange={(e) => setValue(e.detail)}
/>
<TkInput
label="Base Input"
size="base"
value={value1}
onTkChange={(e) => setValue1(e.detail)}
/>
<TkInput
label="Large Input"
size="large"
value={value2}
onTkChange={(e) => setValue2(e.detail)}
/>
<TkInput
label="Small Input"
size="small"
v-model="value"
/>
<TkInput
label="Base Input"
size="base"
v-model="value1"
/>
<TkInput
label="Large Input"
size="large"
v-model="value2"
/>
Icon​
This example illustrates how to use an icon with the input field.
String Usage - Single
Icon Options Usage - Single
String Icon Usage - Multiple
Icon Options Usage - Multiple
- React
- Vue
- Angular
<div className="flex flex-col">
<h4>String Usage - Single</h4>
<div className="flex gap-2">
<TkInput label="Left Icon" icon="flight" />
<TkInput label="Right Icon" icon="flight" iconPosition="right" />
</div>
<TkDivider />
<h4>Icon Options Usage - Single</h4>
<div className="flex gap-2">
<TkInput label="Left Icon" icon={{ name: 'home', color: 'red', fill: true } as IIconOptions} iconPosition="left" />
<TkInput label="Right Icon" icon={{ name: 'home', color: 'red', fill: true } as IIconOptions} iconPosition="right" />
</div>
<TkDivider />
<h4>String Icon Usage - Multiple</h4>
<div className="flex gap-2">
<TkInput
label="Multiple Icon"
icon={
{
left: 'key',
right: 'check_circle',
} as IMultiIconOptions
}
iconPosition="left"
/>
</div>
<TkDivider />
<h4>Icon Options Usage - Multiple</h4>
<div className="flex gap-2">
<TkInput
label="Multiple Icon"
icon={
{
left: { name: 'key', color: 'var(--blue-500)' } as IIconOptions,
right: { name: 'check_circle', color: 'var(--green-600', fill: true } as IIconOptions,
} as IMultiIconOptions
}
iconPosition="left"
/>
</div>
</div>
<div class="flex flex-col">
<h4>String Usage - Single</h4>
<div class="flex gap-2">
<TkInput label="Left Icon" icon="flight" />
<TkInput label="Right Icon" icon="flight" iconPosition="right" />
</div>
<TkDivider />
<h4>Icon Options Usage - Single</h4>
<div class="flex gap-2">
<TkInput
label="Left Icon"
:icon="{ name: 'home', color: 'red', fill: true }"
iconPosition="left"
/>
<TkInput
label="Right Icon"
:icon="{ name: 'home', color: 'red', fill: true }"
iconPosition="right"
/>
</div>
<TkDivider />
<h4>String Icon Usage - Multiple</h4>
<div class="flex gap-2">
<TkInput
label="Multiple Icon"
:icon="{
left: 'key',
right: 'check_circle'
}"
iconPosition="left"
/>
</div>
<TkDivider />
<h4>Icon Options Usage - Multiple</h4>
<div class="flex gap-2">
<TkInput
label="Multiple Icon"
:icon="{
left: { name: 'key', color: 'var(--blue-500)' },
right: { name: 'check_circle', color: 'var(--green-600)', fill: true }
}"
iconPosition="left"
/>
</div>
</div>
State​
This example illustrates the disabled, readonly, and invalid states of the input field. Each state demonstrates how the input behaves and visually changes in different interaction scenarios.
- React
- Vue
- Angular
<TkInput
label="Error"
placeholder="Error"
invalid={true}
error="Bu alan zorunludur"
/>
<TkInput
label="Readonly"
placeholder="Readonly"
readonly
/>
<TkInput
label="Disabled"
placeholder="Disabled"
disabled
/>
<TkInput
label="Error"
placeholder="Error"
:invalid="true"
error="Bu alan zorunludur"
/>
<TkInput label="Readonly" placeholder="Readonly" readonly />
<TkInput label="Disabled" placeholder="Disabled" disabled />
Clearable​
This example clears the input.
- React
- Vue
- Angular
<TkInput
label="Clearable Input"
clearable
value={value}
onTkChange={(e) => setValue(e.detail)}
onTkClearClick={() => setValue(null)}
/>
<TkInput
label="Clearable Input"
clearable
v-model="value"
@tkClearClick="() => value = null"
/>
Chips Mode​
This example illustrates how "chips" mode can be used.
- React
- Vue
- Angular
<TkInput
label="Chips Mode"
mode="chips"
value={value}
onTkChange={(e) => setValue(e.detail)}
/>
<TkInput
label="Chips Mode"
mode="chips"
v-model="value"
/>
Label with Tooltip​
This example illustrates how to use a tooltip with a label.
- React
- Vue
- Angular
<div className="flex flex-col gap-1">
<div className="flex items-center gap-2 mx-2">
<div className="text-sm">Label</div>
<TkTooltip
header="Tooltip Example?"
description="Tooltip description example"
variant="white"
>
<TkIcon icon="info" fill variant="info" slot="trigger" />
</TkTooltip>
</div>
<TkInput />
</div>
<div class="flex flex-col gap-1">
<div class="flex items-center gap-2 mx-2">
<div class="text-sm">Label</div>
<TkTooltip
header="Tooltip Example?"
description="Tooltip description example"
variant="white"
>
<TkIcon icon="info" fill variant="info" slot="trigger" />
</TkTooltip>
</div>
<TkInput />
</div>
API​
Props​
Name | Type | Default | Description |
---|---|---|---|
string | 'label' | The key to use for option labels | |
IChipOptions | null | Sets options for all chips rendered in chips mode. | |
boolean | false | Indicates whether the input can be cleared | |
boolean | false | the user cannot interact with the input. | |
string | null | This is the error message that will be displayed. | |
string | null | Provided a hint or additional information about the input. | |
IIconOptions, IMultiIconOptions, string | null | Specifies a material icon name to be displayed. | |
"left", "right" | 'left' | Defines the position of the icon. | |
boolean | false | Indicates whether the input is in an invalid state | |
string | null | Defines the label for the input. | |
IInputMaskOptions | null | The maskOptions prop is used to define masking configurations supported by the Cleave.js library. With this prop, you can specify any masking options described in the Cleave.js documentation (https://nosir.github.io/cleave.js/). For example, you can configure it for formatting dates, phone numbers, or credit card numbers as needed. | |
number, string | null | Maximum value for number inputs | |
number, string | null | Minimum value for number inputs | |
"chips", "counter", "number", "password", "text" | 'text' | input type | |
string | null | The name of the control, which is submitted with the form data. | |
string | null | Placeholder text displayed when the input is empty. | |
string | null | Defines the prefix of the input; | |
boolean | false | If true , the user cannot modify the value. | |
boolean | false | Displays a red asterisk (*) next to the label for visual emphasis. | |
boolean | false | if type = password safety status bar visible | |
"base", "large", "small" | 'base' | Sets size for the component. | |
string | null | Sets step for decimal value with mode number | |
any[], number, string, string[] | null | The value of the input. |
Events​
Name | Description |
---|---|
tk-blur | Emitted when the input loses focus. |
tk-change | Emitted when the value has changed. |
tk-clear-click | Emitted when the clear button has click. |
tk-focus | Emitted when the input has focus. |
Methods​
Name | Description |
---|---|
setFocus | Sets focus on the specified tk-input . Use this method instead of the global input.focus() . |
Interfaces​
See cleave.js documentation https://nosir.github.io/cleave.js
interface IInputMaskOptions {
backspace?: boolean;
blocks?: number[];
blocksLength?: number;
copyDelimiter?: boolean;
creditCard?: boolean;
creditCardStrictMode?: boolean;
creditCardType?: string;
date?: boolean;
dateFormatter?: any;
dateMax?: string;
dateMin?: string;
datePattern?: string[];
delimiter?: string;
delimiterLazyShow?: boolean;
delimiterLength?: number;
delimiters?: any[];
initValue?: string;
letterOnly?: boolean;
lowerCase?: boolean;
maxLength?: number;
noImmediatePrefix?: boolean;
numeral?: boolean;
numeralDecimalMark?: string;
numeralDecimalScale?: number;
numeralIntegerScale?: number;
numeralPositiveOnly?: boolean;
numeralThousandsGroupStyle?: string;
numericOnly?: boolean;
phone?: boolean;
phoneFormatter?: any;
phoneRegionCode?: string;
prefix?: string;
prefixLength?: number;
rawValueTrimPrefix?: boolean;
result?: string;
signBeforePrefix?: boolean;
stripLeadingZeroes?: boolean;
swapHiddenInput?: boolean;
tailPrefix?: boolean;
time?: boolean;
timeFormat?: string;
timeFormatter?: any;
timePattern?: string[];
uppercase?: boolean;
}