Skip to main content

Text Input

Sizes and Width​

Get small to large text inputs easily by using the size prop. Text Inputs are block elements. You can change the width of them using the width prop.


import { TextInput } from 'chic-ui';

<TextInput placeholder='Type something...' size='large' />
<TextInput placeholder='Type something...' width='300px' size='small'/>

Icons​

Use icons within the text input using the icon prop.

import { TextInput } from 'chic-ui';

<TextInput className="single" placeholder="Enter Full Name" icon={FaUserAlt} />;

Types​

Text Inputs can have error, disabled and readonly types.



import { TextInput } from "chic-ui";
<TextInput placeholder="Errorrrr Eroooorrr!" width="400px" error />
<TextInput placeholder="Disabled Input 😴" width="400px" disabled />
<TextInput placeholder="You can only read me 😈" width="400px" readonly />

Clearable​

To clear the input, add the clearable prop and the UseState hook.

import React, { useState } from 'react';
import { TextInput } from 'chic-ui';

const Clearable = () => {
const [value, setValue] = useState('');
return (
<TextInput
placeholder="Type and clearrr..."
width="400px"
value={value}
onChange={(e) => setValue(e.currentTarget.value)}
clearable
/>;
)}

API​

import { TextInput } from 'chic-ui';
NameTypeDefaultDescription
widthstring'100%'Width of Text Input
size'small' | 'default' | 'large''default'Size of Text Input
iconElementTypeAdd icons to Text Input
errorbooleanfalseShows Error Text Input
disabledbooleanfalseDisable Text Input
readonlybooleanfalseReadOnly Text Input
clearablebooleanfalseClearable Text Input
valuestringSet Value for Text Input
onChangeChangeEventHandler: HTMLInputElementHandles value changes
classNamestringProvide external classnames to the component
styleReact.CSSPropertiesOverride default styling of the component