Capture user data with various forms of text input.
import { Field, Input } from '@fluxui-dev/react';<Field name="username"> <Field.Label>Username</Field.Label> <Field.Description>This will be publicly displayed.</Field.Description> <Input /> <Field.Error /></Field>
Because using the field component in its full form can be verbose and repetitive, all form controls in Flux allow you to pass a label and a description prop directly. Under the hood, they will be wrapped in a field with an error component automatically.
<Input label="Username" description="This will be publicly displayed." />
Unlike other form components, Flux's input component is composed of two underlying elements: an input element and a wrapper div. The wrapper div is there to add padding where icons should go.
This is typically fine, however, if you need to pass classes into the input component and have them directly applied to the input element, you can do so using the inputClassName prop instead of simply className:
<Input className="max-w-xs" inputClassName="font-mono" />
Use the browser's various input types for different situations: text, email, password, etc.
<Input type="email" label="Email" /><Input type="password" label="Password" /><Input type="date" max="2999-12-31" label="Date" />
Flux provides a special input component for file uploads. It's a simple wrapper around the native input[type="file"] element.
<Input type="file" label="Logo" /><Input type="file" label="Attachments" multiple />
Use the size prop to make the input's height more compact.
<Input size="sm" placeholder="Filter by..." />
Prevent users from interacting with an input by disabling it.
<Input disabled label="Email" />
Useful for locking an input during a form submission.
<Input readOnly variant="filled" />
Signal to users that the contents of an input are invalid.
<Input invalid />
Append or prepend an icon to the inside of a form input.
import { CreditCardIcon, LoadingIcon, MagnifyingGlassIcon } from '@fluxui-dev/react/icons';<Input icon={MagnifyingGlassIcon} placeholder="Search orders" /><Input iconTrailing={CreditCardIcon} placeholder="4444-4444-4444-4444" /><Input iconTrailing={LoadingIcon} placeholder="Search transactions" />
Pass an element such as a Button to iconTrailing to place a button inside the input.
import { Button } from '@fluxui-dev/react';import { EyeIcon, XMarkIcon } from '@fluxui-dev/react/icons';<Input placeholder="Search orders" iconTrailing={<Button size="sm" variant="subtle" icon={XMarkIcon} className="-mr-1" />}/><Input type="password" defaultValue="password" iconTrailing={<Button size="sm" variant="subtle" icon={EyeIcon} className="-mr-1" />}/>
Flux provides three special input properties to configure common input button behaviors. clearable for clearing contents, copyable for copying contents, and viewable for toggling password visibility.
import { KeyIcon } from '@fluxui-dev/react/icons';<Input placeholder="Search orders" clearable /><Input type="password" defaultValue="password" viewable /><Input icon={KeyIcon} defaultValue="FLUX-1234-5678-ABCD-EFGH" readOnly copyable />
Hint to users what keyboard shortcuts they can use with this input.
<Input kbd="⌘K" icon={MagnifyingGlassIcon} placeholder="Search..." />
Attach buttons to the beginning or end of an input element.
import { PlusIcon } from '@fluxui-dev/react/icons';<Input.Group> <Input placeholder="Post title" /> <Button icon={PlusIcon}>New post</Button></Input.Group>
Append text inside a form input, or place it between two inputs with Input.Group.Affix.
<Input.Group> <Input.Group.Prefix>https://</Input.Group.Prefix> <Input placeholder="example.com" /></Input.Group><Input.Group> <Input placeholder="chunky-spaceship" /> <Input.Group.Suffix>.brand.com</Input.Group.Suffix></Input.Group><Input.Group> <Input placeholder="Min" /> <Input.Group.Affix>to</Input.Group.Affix> <Input placeholder="Max" /></Input.Group>
If you want to use an input group in a form field with a label, you will need to wrap the input group in a Field component.
<Field name="website"> <Field.Label>Website</Field.Label> <Input.Group> <Input.Group.Prefix>https://</Input.Group.Prefix> <Input placeholder="example.com" /> </Input.Group> <Field.Error /></Field>
|
Prop
|
Description
|
|---|---|
| label |
Label text displayed above the input. When provided, wraps the input in a Field component with an adjacent Field.Label component. See the field component.
|
| description |
Help text displayed above the input. When provided alongside label, appears between the label and input within the Field wrapper. See the field component.
|
| descriptionTrailing |
Help text displayed below the input. When provided alongside label, appears below the label and input within the Field wrapper. See the field component.
|
| badge |
Text displayed after the label as a badge (e.g., "Required").
|
| error |
Error message displayed below the input, marking it invalid and defaulting to the validation error for the input's name.
|
| value |
Controlled value of the input, paired with onValueChange.
|
| defaultValue |
Initial value of the input when uncontrolled.
|
| onValueChange |
Callback fired when the value changes, receiving the new value (onChange is also supported for the raw event).
|
| type |
The HTML type of the input, such as email, password, date, or file. Default: text.
|
| placeholder |
Placeholder text displayed when the input is empty.
|
| size |
Size of the input. Options: base (default), sm, xs. A number sets the native size attribute.
|
| variant |
Visual style variant. Options: filled. Default: outline.
|
| disabled |
Prevents user interaction with the input.
|
| readOnly |
Makes the input read-only.
|
| invalid |
Applies error styling to the input.
|
| multiple |
For file inputs, allows selecting multiple files.
|
| icon |
Icon component (such as MagnifyingGlassIcon) or custom element displayed at the start of the input.
|
| iconTrailing |
Icon component or custom element, such as a Button, displayed at the end of the input.
|
| iconVariant |
Variant of the input's icons, including its clear, copy, view, and expand buttons: outline, solid, mini, or micro. Default: mini.
|
| kbd |
Keyboard shortcut hint displayed at the end of the input.
|
| loading |
If true, displays a loading spinner at the end of the input.
|
| clearable |
If true, displays a clear button when the input has content.
|
| copyable |
If true, displays a copy button to copy the input's content (https only).
|
| viewable |
For password inputs, displays a toggle to show/hide the password.
|
| className |
CSS classes applied to the wrapper element. With label set, they stay on the wrapper, between the label and the input; to space the whole field, write the Field yourself and pass it className.
|
| inputClassName |
CSS classes applied directly to the input element instead of the wrapper.
|
|
Attribute
|
Description
|
|---|---|
| data-flux-input |
Applied to the root element for styling and identification.
|
|
Prop
|
Description
|
|---|---|
| label, description, error |
Shorthand props that wrap the entire group in a single Field, so an error marks every input in the group invalid.
|
|
Slot
|
Description
|
|---|---|
| children |
The input group content, typically containing an input and prefix/suffix elements.
|
|
Prop
|
Description
|
|---|---|
| size |
Size of the prefix. Options: base (default), sm, xs.
|
|
Slot
|
Description
|
|---|---|
| children |
Content displayed before the input (e.g., icons, text, buttons).
|
|
Prop
|
Description
|
|---|---|
| size |
Size of the suffix. Options: base (default), sm, xs.
|
|
Slot
|
Description
|
|---|---|
| children |
Content displayed after the input (e.g., icons, text, buttons).
|
|
Slot
|
Description
|
|---|---|
| children |
Text placed between controls in a group, such as "to" between a minimum and maximum input.
|