Data input

Input Group

One input with icons, text or buttons inside its border, either inline or as joined addon segments.

Class nameTypeDescription
input-groupplf:input-groupComponentAn input with icons, text or buttons inside its border
input-group-controlplf:input-group-controlPartThe native input
input-group-textplf:input-group-textPartShort text before or after the input
input-group-iconplf:input-group-iconPartA decorative SVG icon; an icon class there doesn't need it
input-group-actionplf:input-group-actionPartA button inside the group
input-group-addonplf:input-group-addonPartAn affix joined as a muted segment
input-group-comboboxplf:input-group-comboboxPartA Combobox joined as a segment
input-group-smplf:input-group-smSizeSmall
input-group-lgplf:input-group-lgSizeLarge
input-group-custom-clearplf:input-group-custom-clearModifierHides the browser's own clear button on a search input

A decorative trailing icon; this example does not search a service.

Clear button

data-plf-clear shows the button while the field holds a value; it empties the field and returns focus to it. An empty clear button draws an x.

Clear resets this field and returns focus to it; no remote search.

Password toggle

data-plf-password-toggle shows or hides the password and keeps the selection; it draws an eye, crossed out while the password shows. Two icons of yours take its place: the first, and the second while the password shows.

Use the eye button to show or hide the password; Space or Enter works too. The value and selection are retained.

Joined addons

An affix is not part of the submitted value, so name units or protocols in the label or help text; a Combobox joins the same way with input-group-combobox.

Enter a domain and path. The application adds https://; the visual prefix is not part of this field's value.

The suffix is text, not a button. The numeric value excludes the suffix.

Joined icon segments share the field border. Reset restores this example's initial search value.

Error: supply a value. The complete group has an invalid border.

Disabled

A disabled input mutes the whole group, but each button in it needs disabled as well.

JavaScript

The clear button and password toggle need JavaScript, so author them hidden. 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">
<link rel="stylesheet" href="icons/icons.min.css">
<script src="pelatform-ui.min.js" defer></script>
<link rel="stylesheet" href="pelatform-ui.prefixed.min.css">
<link rel="stylesheet" href="icons/icons.prefixed.min.css">
<script src="pelatform-ui.min.js" defer></script>
Attribute Purpose
data-plf-clear On an input-group-action button beside the group’s one <input>: shows while the field holds a value and is editable, then empties it, sends an input event and focuses the field. Named Clear unless it has a name
data-plf-password-toggle On an input-group-action button beside an <input type="password">: shows or hides the password, keeps the selection and sets aria-pressed. Named Show password unless it has a name
Method Behavior
PLF.InputGroup.getOrCreateInstance(button) Returns the button’s instance, creating it for valid markup
PLF.InputGroup.getInstance(button) Returns the instance or null
instance.destroy() Removes listeners and what the script added, so the button is hidden again; the field keeps its value

After setting the field’s value in code, dispatch an input event so the clear button follows.

React

InputGroup from @pelatform/react renders the group around its parts, in which an Icon needs no class; InputGroupClear and InputGroupPasswordToggle do what the two hooks do.

Prop Values Default
size sm, lg The default size
customClear true hides the browser’s own clear button on a search input false
addon On InputGroupText and InputGroupAction, true joins the part as a muted segment false
aria-label On InputGroupClear and InputGroupPasswordToggle, the button’s name Clear, Show password

The parts:

Part Element
InputGroupControl An input with input-group-control, a direct child of InputGroup, which takes its Field’s label, help and error
InputGroupText A span with input-group-text
InputGroupAddon A span with input-group-addon
InputGroupAction A button with input-group-action, type="button" unless given another type
InputGroupClear An InputGroupAction hidden while the control is empty, disabled or read-only; a click empties the control with an input event, so its onChange follows, and focuses it
InputGroupPasswordToggle An InputGroupAction with aria-pressed, which shows or hides the password and keeps the selection

Other props are the element’s own, className and ref included.

CSS variables

Input Group shares the Input variables; override them on a root or on a single group.

Variable Default
--plf-input-height Minimum height: 2.25rem (36px); 2rem (32px) with input-group-sm, 2.5rem (40px) with input-group-lg
--plf-input-bg, --plf-input-color --plf-color-field, --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-focus-width, --plf-input-focus-color --plf-focus-width (2px), --plf-focus-color, around the whole group
--plf-input-focus-offset 0px, so the ring sits just outside the border
--plf-input-group-icon-size --plf-control-icon-size (16px); 14px with input-group-sm, 18px with input-group-lg
--plf-input-group-icon-color --plf-color-text-muted; addon icons take the addon color
--plf-input-addon-bg --plf-color-surface-raised
--plf-input-addon-color --plf-color-text-muted
--plf-input-addon-border --plf-input-border, the segment divider, so it matches the group’s border
--plf-input-addon-hover-bg --plf-color-surface-muted, on addon buttons

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