Input Group

View as Markdown

An input with icons, words or a button inside its frame, such as a search box or a price.

Letters, numbers and dashes.

When to use

An input with icons, words or a button inside its frame, such as a search box or a price. Use Input instead when the input needs nothing inside its frame.

Usage

import { Input } from "./ui/uicontext/components/FormControls.ts"import { inAddons, InputAddons } from "./ui/uicontext/components/InputAddons.ts"
export const Website = <M>(h: Html.H<M>) =>	InputAddons(h, { start: [{ text: "https://" }] }, Input(h, { style: inAddons }).attrs({ "aria-label": "Website", placeholder: "example.com" }))

Examples

A price and a unit

content takes any control, such as a currency picker. Fixed words are hidden from screen readers, so the label says “in kg”.

API reference

InputAddonsView function

Options

InputAddons options
NameTypeDescription
startInputAddon<Message>[]—
endInputAddon<Message>[]—
dir"ltr""ltr" for what always reads left to right, such as a URL, a key or code, in a right-to-left page too.
styleStyle—

InputView function

Options

Input options
NameTypeDefaultDescription
invalidboolean—Marks the value as wrong: a red border, and aria-invalid for assistive technology.
size"sm" | "md"mdsm for toolbars, table rows and side panels, a control's height; md for forms; md by default.
styleStyle—StyleX styles applied after the control's own.

SelectView function

Options

Select options
NameTypeDefaultDescription
invalidboolean—Marks the value as wrong: a red border, and aria-invalid for assistive technology.
size"sm" | "md"mdsm for toolbars, table rows and side panels, a control's height; md for forms; md by default.
styleStyle—StyleX styles applied after the control's own.

TextareaView function

Options

Textarea options
NameTypeDefaultDescription
invalidboolean—Marks the value as wrong: a red border, and aria-invalid for assistive technology.
size"sm" | "md"mdsm for toolbars, table rows and side panels, a control's height; md for forms; md by default.
styleStyle—StyleX styles applied after the control's own.

InputGroupView function

Options

InputGroup options
NameTypeDescription
startstring—
endstring—
styleStyle—

FormFieldView function

Options

FormField options
NameTypeDefaultDescription
idrequiredstring—The control's id. The label, description and error take ids made from it.
labelrequiredstring—The label's text, which names the control.
descriptionstring—A hint under the control, read out with it.
errorstring—What's wrong with the value. Shown under the control, announced, and marks the control invalid.
hintstring—A short note at the end of the label's line: a count such as "12/48", or "Max 5 MB".
hintOverboolean—The hint warns, as a count past its limit does.
requiredboolean—An empty value is an error: a mark after the label, and aria-required on the control.
optionalboolean—May stay empty, said after the label: for a form where most fields are required.
status{ readonly tone: "pending" | "success"; readonly text: string }—Where an async check stands, in the error's place while there's no error: "Checking…", "acme is available".
layout"stacked" | "inline" | "inline-end"stackedWhere the label sits: above the control (text fields, selects, a radio group), or beside it, with the control first (a checkbox) or last (a switch in a settings row); stacked by default
groupboolean—The control is a group of controls (a radio group, a segmented control): a group can't be the target of a <label for>, so the label names it through aria-labelledby instead
labelStyleStyle—StyleX styles for the label: a row field's label that hides behind column headings.
styleStyle—StyleX styles for the field's wrapper.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/input-group

Source