You are currently viewing outdated (<=3.x) Chameleon documentation on our old website. For version >=4.x, check out our new website.

Current release: 3.5.0 | hub

components

AutoComplete (code)

AutoCompletes are input fields where a user is suggested several options, based on the input they provide.

Selected value:

import { AutoComplete } from '@mediahuis/chameleon-react'

Props

NameTypeDefaultRequiredDescription
accessibilityLabelClearButtonString'clear selection'-Accessible friendly label in clear button. Will not be shown.
actionNode--Contents displayed within the ActionLabel.
autoCompleteString'off'-Modifies the html autocomplete attribute.
classNameString--Extend classNames.
disabledBoolean--Whether or not the TextField is disabled
errorBoolean--Visually displayed as error. Will add the necessary a11y tags.
forceSelectionBoolean--Force the user to make a selection.
iconLeftFunctionStringNodeObject--The left icon of the TextField
idString-trueThe id of the TextField (a11y), will also add an id to the wrapper with prefix 'autocomplete-'
labelString-trueThe label used in the TextField
labelHiddenBoolean--Visibly hide the label. (label is still required for a11y)
loadingBoolean--The loading state of the autoComplete: use in combination with async data.
messageString--The message used beneath the textField
nameString--Name of the TextField.
onBlurFunction--The onBlur event of the TextField: called when the input loses focus, e.g. when user presses Tab
onChangeFunction-truesignature: function onChange(value, stateHelpers)
onFocusFunction--Fires when the TextField receives focus.
onInputChangeFunction--AutoComplete will call this function every time you need to update suggestions. Can be used for async.
onSelectFunction--Called when the user selects an item, regardless of the previous selected item. Called with the item that was selected and the new state of downshift. (see onStateChange for more info on stateAndHelpers).
optionalLabelString--Contents displayed within the OptionalLabel.
placeholderString--The placeholder used in the TextField
placement'bottom''top''bottom'-Where are the suggestions positioned towards the TextField element.
readOnlyBoolean--TextField is readOnly or not.
successBoolean--Autocomplete is successfully filled in.
suggestionsArray<String>-trueAn array of suggestions
typeString'text'-The type of the TextField
valueString--Native input value.

System Props

System Props

Next to the properties listed in the propstable, a collection of system props can be added to any component for further general styling and layouting purposes. These props vary per component.

To read more about the system, click here to check out its dedicated page.

ForceSelection

Make sure a user selects one of the selections

Selected value:

Suggestions

default: []

suggestions is a list of strings that may be suggested to the user, based on their input.

OnChange

default: undefined

onChange is triggered on every change made by the user, so when the user types or when user selectes a suggested value, either by keyboard or mouse.

Selected value:

OnInputChange

default: undefined

In contrast to onChange, onInputChange is only triggered when the user types in the input field. The reason this is separated, is to reduce potential API calls when the suggestions are fetched from an API (e.g. streets in an addressform).

Note: when you supply the onInputChange property, the component will no longer automagically filter suggestions on typing. We assume that, since you're using the value of the input yourself, you will provide the updated suggestions to the suggestions prop.

Selected value:

Search term for API:

Loading

default: false

To indicate to a user that, based on their input an API call is being called, you can set the loading prop to true.

Selected value:

Search term for API:

IconLeft

default: undefined

For further illustration purposes, you can provide an iconLeft.

Label Props

As with other input elements, AutoComplete also has a wide range of extra properties to convey even more meaning.

We need your data

© Copyright 2020 Mediahuis NV. All rights Reserved