Control
The bordered field shell shared by Onset's text-entry components: consistent borders, focus rings, and sizing across every input.
Behavior
Control is not a form control itself. It is the visual wrapper that provides the borders, backgrounds, hover treatments, focus rings, and sizing used by Input, Select, Textarea, NumberInput, Autocomplete, and TokenField.
| Prop | Type | Default | Description |
|---|---|---|---|
as | ElementType | "label" | Defaults to label so clicking anywhere in the shell focuses the input inside. |
size | "sm" | "md" | "lg" | "md" | Controls height, padding, font size, and radius. |
disabled | boolean | — | Muted appearance and no pointer events. |
invalid | boolean | — | Red border and red focus ring. Pair with aria-invalid on the inner input. |
readOnly | boolean | — | Subtle background, no border highlight on hover. |
fullWidth | boolean | — | Fills the available width. |
mono | boolean | — | Monospace font for identifiers, hashes, and code. |
autoHeight | boolean | — | Height follows content instead of the size scale. |
wrap | boolean | — | Children wrap onto multiple rows. Implies autoHeight. |
open | boolean | — | Marks the shell as having an open popover attached. |
leading | ReactNode | — | Icon or node before the content. |
trailing | ReactNode | — | Icon or node after the content. |
prefix | ReactNode | — | Static text before the content, inside the border (e.g. $). |
suffix | ReactNode | — | Static text after the content, inside the border (e.g. ms, %). |
Sizes
Three sizes. The metrics are available programmatically via controlSize, a lookup that returns height, paddingX, gap, fontSize, and radius for each size. The same values are emitted as --m-control-height-sm, --m-control-padding-x-md, and so on.
States
Building with Control
Wrap a custom input in Control to get Onset's focus ring and sizing: a date field, a currency picker, a duration entry, and so on.
The focus ring is driven by CSS variables: --m-focus-color (defaults to --m-color-primary), --m-focus-width, --m-focus-offset, --m-focus-outline, and --m-focus-ring. These are token-driven, so a product can restyle focus globally without touching any component.
A currency input built from Control and a native input:
import { Control, controlInputClass } from "@solarius/onset";
export function CurrencyInput() {
return (
<Control prefix={<span>$</span>} suffix="USD" size="md">
<input className={controlInputClass} placeholder="0.00" />
</Control>
);
}CSS classes
Control exports three public CSS class strings for when you need to place elements yourself rather than going through the props.
| Prop | Type | Default | Description |
|---|---|---|---|
controlInputClass | string | — | Strips browser chrome from a bare <input>/<textarea> and inherits the shell's font. |
controlAffixClass | string | — | Styles for a static text affix (prefix/suffix). |
controlSlotClass | string | — | Styles for a leading/trailing icon slot. |
<Control>
<span className={controlSlotClass}>
<Icon icon={IconSearch} />
</span>
<input className={controlInputClass} placeholder="Search..." />
<span className={controlAffixClass}>ms</span>
</Control>In most cases use the leading, trailing, prefix, and suffix props instead; they handle placement and spacing. Use the classes only when you need to place elements yourself.