No Preview

Sorry, but you either have no stories or none are selected somehow.

If the problem persists, check the browser console, or the terminal you've run Storybook from.

Input

import { Input } from '@proton/atoms';

Basic input html element wrapper with disabled/error states, styling, and input adornments.

If you are looking to wrap the input with labels or hint text, please see InputField.
() => { const [value, setValue] = useState(''); const handleValue = (updatedValue: string) => setValue(updatedValue); return <Input placeholder="Placeholder" value={value} onValue={handleValue} />; }

Controlled input

Use the value and onValue props to control the input.

The `disableChange` prop can be used to prevent the input value from updating. Try updating the value from the input below.

() => { const [value, setValue] = useState(''); const handleValue = (updatedValue: string) => setValue(updatedValue); return ( <> <Input placeholder="Placeholder" value={value} onValue={handleValue} /> <p className="mb-1"> The `disableChange` prop can be used to prevent the input value from updating. Try updating the value from the input below. </p> <Input disableChange placeholder="Placeholder" value={value} onValue={handleValue} /> </> ); }

Error state

Use the error prop to add error styling.

Disabled state

Use the disabled prop to disable the input. This prevents the user interacting with the input and adds disabled styling.

Note the disabled styling added to the prefix and suffix

@protonmail.com

Unstyled

Use the unstyled prop to remove any default styling.

Adornments

Use the prefix and suffix props to adorn the input.

@protonmail.com

Props

NameDescriptionDefault
error
ReactNode
-
containerRef
Ref<HTMLDivElement>
-
disabled
boolean
-
prefix
ReactNode
-
suffix
ReactNode
-
unstyled
boolean
-
onValue
((value: string) => void)
-
disableChange
boolean
-
containerProps
(Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & { ref?: ((instance: HTMLDivElement | null) => void) | ... 2 more ...; })
-
inputContainerClassName
string
-
inputClassName
string
-
prefixClassName
string
-