Text Input
A component to get user input inside a text field.
Anatomy
Mount all pieces together and create your input
import { TextInput } from '@micode-ui/react';
<TextInput.Root>
<TextInput.LeftIcon>{/* Your Icon */}</TextInput.LeftIcon>
<TextInput.Input placeholder='Type some text...' />
<TextInput.RightIcon
activeIcon={/* Icon when text is visible */}
inactiveIcon={/* Icon when text not visible */}
/>
</TextInput.Root>;
Example
<Box
css={{
display: 'flex',
flexDirection: 'column',
background: 'transparent',
gap: '$2'
}}
>
<TextInput.Root>
<TextInput.LeftIcon>
<User weight='bold' />
</TextInput.LeftIcon>
<TextInput.Input placeholder='Type your username...' />
</TextInput.Root>
<TextInput.Root>
<TextInput.LeftIcon>
<Envelope weight='bold' />
</TextInput.LeftIcon>
<TextInput.Input placeholder='Type your password...' type='password' />
<TextInput.RightIcon
activeIcon={<Eye weight='bold' />}
inactiveIcon={<EyeSlash weight='bold' />}
/>
</TextInput.Root>
</Box>
API Reference
Root
Contains all parts of the TextInput.
Prop | Type | Default |
---|---|---|
children | ReactNode | |
error | boolean | false |
disabled | boolean | false |
LeftIcon
A feedback icon that sits on the left side of the input field.
Prop | Type | Default |
---|---|---|
children | ReactNode |
Prefix
A prefix text shown before the input text
Prop | Type | Default |
---|---|---|
children | string |
Input
The HTML input itself
Prop | Type | Default |
---|---|---|
children | ReactNode |
RightIcon
A feedback icon/text visibility toggler that sits on the right side of the input field.
Prop | Type | Default |
---|---|---|
activeIcon | ReactNode | |
inactiveIcon | ReactNode |