Back to Onyx

Input Layouts

web/lib/opal/src/layouts/inputs/README.md

3.3.03.1 KB
Original Source

Input Layouts

Import: import { InputVertical, InputHorizontal, ... } from "@opal/layouts";

Layout primitives for form fields. Arrange title, description, input controls, and Formik error messages in vertical or horizontal orientations with optional <label> wrapping. Uses sizePreset="main-ui" internally for all text sizing.

Components

Label

Low-level <label> wrapper with cursor styling. Most consumers should use InputVertical or InputHorizontal with withLabel instead of using Label directly.

PropTypeDefaultDescription
labelstringSets htmlFor to associate with a form element by id
disabledbooleanfalseSwitches cursor to not-allowed

Vertical

Stacks title, description, input, error, and sub-description vertically.

PropTypeDefaultDescription
withLabelboolean | stringfalsefalse: no label. true: implicit label (click-forwarding). string: label with htmlFor + Formik error display.
disabledbooleanfalsePasses through to the label wrapper
titlestring | RichStrSection title
tagTagPropsTag rendered beside the title
descriptionstring | RichStrSection description
subDescriptionstring | RichStrText below the input
suffix"optional" | stringSuffix after the title

Horizontal

Places title/description on the left, input control on the right.

PropTypeDefaultDescription
withLabelboolean | stringfalseSame as Vertical
disabledbooleanfalsePasses through to the label wrapper
centerbooleanfalseVertically center the input with the label
titlestring | RichStrSection title
tagTagPropsTag rendered beside the title
descriptionstring | RichStrSection description
suffix"optional" | stringSuffix after the title

InputErrorText

Renders an error or warning message with an icon.

PropTypeDefaultDescription
childrenReactNodeError/warning message
type"error" | "warning""error"Controls icon and color

InputDivider

A horizontal rule with inline padding for separating field groups.

InputPadder

Wraps children in standard p-2 w-full padding.

Usage

tsx
import { InputVertical, InputHorizontal } from "@opal/layouts";

// Vertical with Formik field binding
<InputVertical withLabel="email" title="Email" description="Your email address">
  <InputTypeInField name="email" />
</InputVertical>

// Horizontal with implicit label (click-forwarding)
<InputHorizontal withLabel title="Notifications" description="Enable notifications">
  <Switch />
</InputHorizontal>

// No label (default) — for non-form children like buttons
<InputHorizontal title="Delete" description="Remove this item">
  <Button variant="danger">Delete</Button>
</InputHorizontal>