v3.0.6

Field

Installation

Install yarn add @spark-web/field
Source GitHub.com
Bundle unpkg.com

Using context, the field component connects the label, description, and message to the input element.

Example

Label

Each field must be accompanied by a label. Effective form labeling helps users understand what information to enter into an input.

Using placeholder text in lieu of a label is sometimes employed as a space-saving method. However, this is not recommended because it hides context and presents accessibility issues.

Label visibility

The label must always be provided for assistive technology, but you may hide it from sighted users when the intent can be inferred from context.

Secondary label

Provide additional context, typically used to indicate that the field is optional.

Adornment

Optionally provide a utility or contextual hint, related to the field.

Description

Provides pertinent information that assists the user in completing a field. Description text is always visible and appears underneath the label. Use sentence-style capitalisation, and in most cases, write the text as full sentences with punctuation.

We take your privacy seriously. We will never give your email to a third party.

Message and tone

The “message” is used to communicate the status of a field, such as an error message. This will be announced on focus and can be combined with a “tone” to illustrate intent.

Critical message
Positive message
Neutral message

Disabled

Mark the field as disabled by passing true to the disabled prop.

Props

PropTypeDescription

children

ReactNode: string | number | false | true | {} | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal

Input component

label

string

Concisely label the field.

adornment?

ReactElement<any, string | JSXElementConstructor<any>>

Optionally provide a utility or contextual hint, related to the field.

data?

DataAttributeMap

Sets data attributes on the component.

description?

string

Provide additional information that will aid user input.

disabled?

boolean

Indicates that the field is perceivable but disabled, so it is not editable

or otherwise operable.

Default: false

id?

string

Sets a unique identifier for the component.

labelVisibility?

"hidden" | "reserve-space" | "visible"

The label must always be provided for assistive technology, but you may

hide it from sighted users when the intent can be inferred from context.

Default: "visible"

message?

string

Provide a message, informing the user about changes in state.

secondaryLabel?

string

Additional context, typically used to indicate that the field is optional.

tone?

"critical" | "positive" | "neutral"

Provide a tone to influence elements of the field, and its input.

Default: "neutral"

© 2023 Brighte Capital Pty Ltd