Input
A themed single-line text field.
Import
import { Input } from '@bedrock-core/ore-styled';
Usage
Render it inside a <Form>. The value arrives in the form's onSubmit, keyed by name.
<Form onSubmit={({ values }) => console.warn(values.nickname)}>
<Input name={'nickname'} label={'Name'} placeholder={'type your name'} width={160} />
<Form.Button type={'submit'}>{'Save'}</Form.Button>
</Form>
It is Input with the theme's field textures and font applied, plus a caption above the box. The widget itself is the engine's — it is owned by the client while the form is open, and every field's value comes back at once on submit.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
name* | string | — | Result key — the value appears at values[name] in the form's onSubmit |
label | string | — | Caption rendered above the field |
placeholder | string | — | Text shown inside the field when it is empty |
defaultValue | string | '' | Initial text |
Inherits every prop of Input — the font, the scale, the text offsets and the per-state box textures — with the theme's values as defaults rather than a lock: pass one and yours wins. Through it, control props as well.
Examples
Two fields in one form
<Form onSubmit={({ values }) => save(values.nickname, values.motto)}>
<Input name={'nickname'} label={'Name'} placeholder={'type your name'} />
<Input name={'motto'} label={'Motto'} defaultValue={'hello'} />
<Form.Button type={'submit'}>{'Save'}</Form.Button>
</Form>
Disabled
<Input name={'locked'} label={'Name'} defaultValue={'Steve'} enabled={false} />
Notes
Give the field a width, or let it stretch in a column, so the framed box reads as a field even when empty. A placeholder keeps an empty one reading as editable.
There is no onChange: a native modal is atomic, so nothing reaches script while the form is open. For a value the screen reacts to immediately, use a press — Checkbox and Toggle do that on the hosts where a press reaches script.
Limits
Modal-only. The engine draws no text field on an action form or a container screen, so useMechanism('Input') refuses it there at build, naming the fix.