Data input

Input

A native text input in a field with a label, help text and error message.

Class nameTypeDescription
inputplf:inputComponentA native text input
fieldplf:fieldComponentA label, a control and its messages
field-labelplf:field-labelPartThe control's label
field-legendplf:field-legendPartThe fieldset's legend
field-helpplf:field-helpPartHelp text
field-errorplf:field-errorPartAn error message
field-requiredplf:field-requiredPartMarks a required field in the label
input-smplf:input-smSizeSmall
input-lgplf:input-lgSizeLarge
field-groupplf:field-groupModifierA fieldset of fields, without its border

Default

The same field parts compose Textarea, native selects, Checkbox, Radio and Switch. Keep a visible label: a placeholder disappears as soon as someone types.

Help text

Put the help text’s id in the input’s aria-describedby.

Example: https://example.test/workspaces/international-customer-success

Required

field-required only marks the label; the native required attribute makes the field required.

Shown alongside your contributions.

Invalid

Your application adds and removes aria-invalid and the error message, whose id follows the help id in aria-describedby; start the message with “Error:” so the state does not rely on color alone.

Use an address you can access.

Error: enter a valid email address.

Errors from your code

PLF.Field.error(control, message) shows your message, such as one your server returns, in the element the control’s aria-errormessage names, until the next edit.

Use an address you can access.

Field group

A disabled fieldset disables every control inside it.

Managed settings

A disabled fieldset disables its inputs through native HTML.

Types

Set dir="ltr" on email, URL and phone values so they stay readable on right-to-left pages.

Read-only

Unlike disabled, readonly keeps the value in the form data.

You can focus and copy this value.

Unavailable values are excluded from form data.

JavaScript

Input itself needs no JavaScript; its examples use Button’s loading state and the error helper, which needs no init(). The Full script (pelatform-ui.min.js) starts every component on page load, with no code of your own; with ESM imports, call init() yourself, as in Installation. For markup you add later, see Dynamic content.

<link rel="stylesheet" href="pelatform-ui.min.css">
<script src="pelatform-ui.min.js" defer></script>
<link rel="stylesheet" href="pelatform-ui.prefixed.min.css">
<script src="pelatform-ui.min.js" defer></script>
Method Behavior
PLF.Field.error(control, message) On any form control inside a root: shows message in the element its aria-errormessage names, sets aria-invalid="true" and adds the message to aria-describedby. The next edit of the control, a reset of its form or an empty message clears all three

With ESM, import Field from @pelatform/ui/components/field.

React

Input from @pelatform/react renders this native input, Field the field around one control and FieldGroup the fieldset around several; the control inside takes the label’s id, the help and error as its description, aria-invalid with an error and required, so you write no ids.

Component Prop Values Default
Input size sm, lg The default size
Field label The label (field-label), which names the control None
Field id The control’s id, which the label names; without a label or id, each control keeps its own, so one Field can describe several A generated id
Field required true makes the control required and marks the label (field-required) false
Field requiredLabel The label’s mark when required (required)
FieldGroup legend The legend (field-legend), which names the group None
Field, FieldGroup help Help text (field-help), which describes the control, or each control in the group None
Field, FieldGroup error An error message after the help (field-error), which makes the controls invalid; start it with “Error:” None

The other props are the element’s own, an input’s, a div’s or a fieldset’s, className and ref included.

CSS variables

Override on a root or on a single control; Input, Textarea, native selects and Input Group share them.

Variable Default
--plf-input-height Minimum height: 2.25rem (36px); 2rem (32px) with input-sm, 2.5rem (40px) with input-lg; when set, it takes precedence over the size classes
--plf-input-bg --plf-color-field; read-only and disabled inputs use their own surfaces. Set --plf-input-border with it when the two must match
--plf-input-color --plf-color-text
--plf-input-border --plf-color-input
--plf-input-hover-border --plf-input-border, otherwise --plf-color-border
--plf-input-invalid-border --plf-color-danger
--plf-input-radius --plf-radius-lg, 0.5rem (8px)
--plf-input-shadow --plf-shadow-xs
--plf-input-font-weight --plf-font-weight-normal (400)
--plf-control-font-size --plf-font-size-sm, 0.875rem (14px), at every size
--plf-input-focus-width, --plf-input-focus-color --plf-focus-width (2px), --plf-focus-color
--plf-input-focus-offset 0px, so the ring sits just outside the border
--plf-field-gap --plf-space-2, 0.5rem (8px), between a field’s parts and below a legend

Built with Pelatform UIv0.1.0

Components

Getting started

Foundations

Components

Actions

Data display

Navigation

Feedback

Data input

Layout

Advanced

Integrations

Blocks

Application

Authentication

Icons