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

Select (code)

Select gives users the ability to select a single item from a list of options.

Jummy!
import { Select } from '@mediahuis/chameleon-react'

Props

NameTypeDefaultRequiredDescription
actionNode--Contents displayed within the ActionLabel.
childrenNode--The content displayed withing the select.
classNameString--Extend classNames.
disabledBoolean--Same as the HTML attribute.
errorBoolean--Visually displayed as error text. Will add the necessary accessibility tags.
iconLeftFunctionNodeObject--The icon on the left (extends Icon), choose one of the icons package.
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)
messageString--Contents displayed beneath the label.
nameString--Name attribute of the HTML element.
onBlurFunction--Fires when the select loses focus.
onChangeFunction--Native change event, validate on event.target.value.
onClickFunction--Function that is fired when the value of the select changes.
onFocusFunction--Fires when the select receives focus.
optionalLabelString--Contents displayed within the OptionalLabel.
placeholderString--First value in options, which is disabled.
requiredBoolean--Sets the native select required attribute.
successBoolean--Property to show a success-state on the select
valueString--Current value of the select.

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.

Disabled

default: undefined

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

Error

default: undefined

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

IconLeft

default: undefined

For further illustration purposes, you can provide an iconLeft.

LabelHidden

default: undefined

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

Message

default: undefined

Give additional information to the user.

Message can be set to provide additional information.

OptionalLabel (Required fields)

default: undefined

By default the Select is always required. To make a Slect 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.

Placeholder

default: undefined

Placeholder text is displayed inside the field but is not always necessary. They should be written as examples helping users to understand the required input instead of instructions.

Required

default: true

By default the Select is required. You can change this by providing a optionalLabel or passing false to the required prop. We encourage you to use the optionalLabel prop, this provides additional feedback to the user!

Value

default: undefined

Use value for controlled Selects.

© Copyright 2020 Mediahuis NV. All rights Reserved