Pillar UI React InputFile Component documentation
Enable users to upload files seamlessly with a customizable InputFile component for React. Streamline file selection and validation for enhanced user experience.
Components:
Type
import
import { Pillar UI React InputFile Component } from '@pillar-ui/core'
props
Filled
A filled input is a type of input field that has a background color. This makes it easy for users to see where they are typing and to distinguish between input fields.
export const InputFileFilled = () => {
return (
<Flex gap="sm" direction="column">
<InputFile aria-label="hello" autoFocus variant="filled" />
<InputFile aria-label="hello" variant="filled" />
<InputFile aria-label="hello" disabled variant="filled" />
<InputFile aria-label="hello" isInvalid variant="filled" />
</Flex>
)
}
Outline
The outline variant of the input component is a type of input field that has a border around it. This makes it easy for users to see where they are typing and to distinguish between input fields.
export const InputFileOutline = () => {
return (
<Flex gap="sm" direction="column">
<InputFile aria-label="hello" autoFocus variant="outline" />
<InputFile aria-label="hello" variant="outline" />
<InputFile aria-label="hello" disabled variant="outline" />
<InputFile aria-label="hello" isInvalid variant="outline" />
</Flex>
)
}
Bordered
The bordered variant of the input component is a type of input field that has a bottom border that visually separates the input from others and shows the edge of the input.
export const InputFileBordered = () => {
return (
<Flex gap="sm" direction="column">
<InputFile aria-label="hello" autoFocus variant="bordered" />
<InputFile aria-label="hello" variant="bordered" />
<InputFile aria-label="hello" disabled variant="bordered" />
<InputFile aria-label="hello" isInvalid variant="bordered" />
</Flex>
)
}
Corner
The corner prop is a prop that can be used to customize the corner radius of the InputFile component. Valid values for the corner prop are: sharp
| xs
| sm
| md
| lg
| xl
| full
export const InputFileCorner = () => {
return (
<Flex gap="sm" direction="column">
<InputFile corner="sharp" placeholder="sharp" />
<InputFile corner="xs" placeholder="xs" />
<InputFile corner="sm" placeholder="sm" />
<InputFile corner="md" placeholder="md" />
<InputFile corner="lg" placeholder="lg" />
<InputFile corner="xl" placeholder="xl" />
<InputFile corner="full" placeholder="full" />
</Flex>
)
}
Color
- Type: string
- Default:
primary
- Options:
danger
|warning
|success
|primary
|secondary
|bg
The color prop can be used to customize the color of the input's border when it is focused. Valid values for the color prop are: primary
| purple
| secondary
| brown
| bg
export const InputFileColor = () => {
return (
<Flex gap="sm" direction="column">
<InputFile color="pri" variant="bordered" autoFocus placeholder="Focus" />
<InputFile color="war" variant="bordered" autoFocus placeholder="Normal" />
<InputFile color="sec" variant="outline" autoFocus placeholder="Disabled" />
<InputFile color="bg" variant="filled" autoFocus placeholder="isInvalid" />
<InputFile
color="suc"
variant="bordered"
autoFocus
prefixInputFile={<User width="16" />}
placeholder="Placeholder"
/>
<InputFile
color="dan"
variant="bordered"
autoFocus
prefixInputFile={'https://'}
suffixInputFile=".com"
defaultValue="Default Value"
/>
</Flex>
)
}
Size
- Type: string
- Default:
md
- Options:
2xs
|xs
|sm
|md
|lg
|xl
|2xl
The size prop of the input component is used to change the size of the input field. The default size is medium md
. The following values are supported: sm
,lg
import { Flex, InputFile } from '@pillar-ui/core'
export const InputFileSize = () => {
return (
<Flex gap="sm" direction="column">
<InputFile size="sm" placeholder="Small(sm)" />
<InputFile placeholder="Medium (md default You don't need it)" />
<InputFile size="lg" placeholder="Large(lg)" />
</Flex>
)
}
Best Practice
- Use clear and concise labels. The label should be descriptive and accurate, and it should clearly indicate what information is being requested to add label to the input Please wrap it within a FormField Component.
- Use placeholder text. The placeholder text should provide a hint to the user about what information is expected.
- Use a consistent style for all input fields. This will help to create a more visually appealing and user-friendly interface. Choose only one variant and use it consistently throughout your site. Do not mix variants within the same site.
- Validate the input data on both the client and server side. This will help to ensure that the user enters the correct information and provide a good user experience.
- Provide feedback to the user about the validity of their input data. Use FormController to send error messages to the component, which will then display them to the user.
- If your input field needs more information, use the hint prop to provide that information to the user. This will help the user to understand what information is expected and to enter the correct information.
Troubleshooting
If you encounter any issues with the InputFile component, make sure that you have correctly passed the props and values. If you are still having issues, check the console for any error messages.
Conclusion
The InputFile component is a versatile UI component that can be used to collect user input. It is flexible, customizable, and accessible, making it a great addition to any UI design.