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

TextField (code)

A TextField is an interactive control used in forms to collect data from the user.

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

Props

NameTypeDefaultRequiredDescription
accessibilityLabelClearButtonString'Clear'-The a11y label for the clearButton
actionNode--Contents displayed within the ActionLabel.
classNameString--Extend classNames.
clearButtonBoolean--show or hide clearButton
disabledBoolean--Sets the HTML disabled attribute.
errorBoolean--Visually displayed as error text. Will add the necessary accessibility tags.
iconLeftFunctionStringNodeObject--Name of the icon on the left (extends Icon), choose one of the icons package.
iconLeftComponentNode--iconLeftComponent replaces iconLeft, you can add any component here.
iconRightFunctionStringNodeObject--Name of the icon on the left (extends Icon), choose one of the icons package.
iconRightComponentNode--iconRightComponent replaces iconRight, you can add any component here.
idString-trueNative HTML id attribute. Will also affect the label-id, and the message-id. For accessibility reasons.
labelNode-trueContents displayed within the PrimaryLabel.
labelHiddenBoolean--Visibly hide the label. (label is still required for a11y)
maskString--Helps the user with the input by ensuring a predefined format. This can be useful for dates, numerics, phone numbers, ...
messageString--Contents displayed beneath the input.
nameString--Name of the form element.
onBlurFunction--Fires when the TextField loses focus.
onChangeFunction--Will trigger when the TextField's value changes.
onFocusFunction--Fires when the TextField receives focus.
onIconLeftClickFunction--Click event for the iconLeft, (not for iconLeftComponent, there the click event is placed on the component itself).
onIconRightClickFunction--Click event for the iconLeft, (not for iconRightComponent, there the click event is placed on the component itself).
optionalLabelString--Contents displayed within the OptionalLabel.
successBoolean--TextField is successfully filled in.
typeString'text'-The type of the input.
valueStringNumber--The value of the input.

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.

Action

default: undefined

Adds an action or extra information to your item, mostly used for links.

OptionalLabel (Required fields)

default: undefined

By default the TextField is always required. To make a TextField optional you can add the optionalLabel prop.

With Chameleon we take a specific approach where we encourage marking optional fields, not required. The majority of fields in a form are always required. Indicating that fields are required make users more fearful, it increases the risk of errors and reduces the form completion rate.

Error

default: undefined

To convey an error to the user, you can set the error prop to true.

Success

default: undefined

To convey a success state to the user, you can set the success prop to true.

Disabled

default: undefined

Marking a TextField as disabled, will disable all interaction with the element.

IconLeft

default: undefined

For further illustration purposes, you can provide an iconLeft.

LabelHidden

default: undefined

To meet accessibility requirements, every TextField should have an associated label. We do support the ability to visually hide the label when the TextField's purpose is clear.

Message

default: undefined

Give additional information to the user.

Multiple inputs should have space 5 between them.

Mask

default: undefined

To visually aid the user with the expected format, you can use an input mask. Input masks will display a template of the expected value. The mask is built out of several definitions:

  • 9: numeric
  • a: alphabetical
  • *: alphanumeric

© Copyright 2020 Mediahuis NV. All rights Reserved