Description
The input component is an umbrella component for all inputs which share the same style as the classic text
input field.
NB: Is InputMasked what you are looking for?
Demos
Placeholder text
<Input label="Label:" placeholder="Placeholder text" />
Search text placeholder
<Inputlabel="Search:"type="search"placeholder="Search text placeholder"on_change={({ value }) => {console.log('on_change', value)}}on_submit={({ value }) => {console.log('Submit:', value)}}/>
Medium and stretched search input
<Inputsize="medium"type="search"stretch={true}value="Medium search value"on_change={({ value }) => {console.log('on_change', value)}}/>
Input with icon
With left / right aligned text
<Inputlabel="Input with icon:"placeholder="Input"label_direction="vertical"icon="check"bottom/><Inputlabel="Input with icon:"label_sr_onlyplaceholder="Input with a placeholder"icon_position="right"icon="check"align="right"/>
Disabled input
<Inputdisabledlabel="Disabled input:"placeholder="Disabled Input with a placeholder"/>
With FormStatus
You have to fill in this field
You have to fill in this field
<FormRow bottom><Inputlabel="With FormStatus:"status="You have to fill in this field"value="Input value with error"/></FormRow><FormRow><Inputlabel="With button:"status="You have to fill in this field"value="Input value with error"type="search"/></FormRow>
Input with suffix (additional description)
<Inputlabel={<Space element="span" className="dnb-h--large">Fødselsnummer</Space>}label_direction="vertical"autocomplete="on"placeholder="Placeholder text"suffix={<HelpButton title="Info" size="large">Some content</HelpButton>}on_change={({ value }) => {console.log('on_change', value)}}/>
Input
in horizontal wrapping FormRow
and a long label
Stretched <FormRowlabel="Long label labwl Adipiscing mauris dis proin nec:"vertical><Inputvalue="I stretch ..."stretchstatus="Status message"status_state="warn"/></FormRow>
Numbers are using DNB Mono (monospace)
Also, this example manipulates the value during typing.
Numbers are using DNB Mono (monospace)
<Inputlabel="Label:"autocomplete="on"placeholder="Placeholder text"status="Numbers are using DNB Mono (monospace)"status_state="info"value="1234567890"on_change={({ value }) => {console.log('on_change', value)return String(value).toUpperCase()}}/>
Submit Form with Input
Pressing the enter key will trigger a submit.
<FormSetprevent_submit={true}on_submit={(event) => {console.log('FormRow.on_submit', event)}}><FormRow><Inputtype="search"label="Label:"value="Input ..."selectall={true}on_submit={(event) => {console.log('Input.on_submit', event)}}on_change={({ value }) => {console.log('on_change:', value)}}right="small"bottom="x-small"/><Button text="Submit" type="submit" /></FormRow></FormSet>
Input with clear button
Pushing the clear button or pressing the ESC key will clear the input.
<FormRow direction="vertical"><Input clear={true} value="Value ..." size="medium" /><Input clear={true} value="Value ..." type="search" top /><Input clear={true} value="Value ..." icon="loupe" type="search" top /></FormRow>
Input password type
The password component has to ensure that there is still room for password managers to inject the input with their UX functionality.
In order to get the show/hide button, you may have to import the component like so:
import InputPassword from '@dnb/eufemia/components/input/InputPassword'
<InputPasswordlabel="Label:"placeholder="A placeholder text"on_change={({ value }) => {console.log('on_change:', value)}}on_show_password={() => {console.log('on_show_password')}}on_hide_password={() => {console.log('on_hide_password')}}/>