Back to Onyx

Input Layouts

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

4.4.0-lite-open-url24.0 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
iconIconFunctionComponentOptional icon rendered beside the title
responsivebooleanfalseStack the control between title and description on narrow viewports (floats back to the right at sm). Best for text inputs; avoid for compact controls like toggles.
fillInputbooleanfalseGrow the control to fill the row (capped at the form input-column max, 240px) instead of hugging its content. Use for full-width inputs like selects/text fields; avoid for compact controls like toggles/switches. Forwarded to ContentAction as fillRight.
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>

// Full-width input — the select grows to fill the row (capped at 240px)
<InputHorizontal
  withLabel="visibility"
  title="Query History Visibility"
  description="Control what is shown in query history"
  fillInput
>
  <InputSelect ... />
</InputHorizontal>