Skip to main content

Input

Single-line text field, for use inside a Form.

Import​

import { Form, Input } from '@bedrock-core/ui';

Usage​

<Form onSubmit={v => console.warn(v.nickname)}>
<Input name={'nickname'} placeholder={'§7type here'} />
<Form.Button type={'submit'}>{'Save'}</Form.Button>
</Form>

How it works​

Input is a pure field declaration — no onChange / controlled value. It renders to the native ModalFormData.textField control; the result (string) arrives at values[name] in the form's onSubmit, once, on submit.

Props​

PropTypeDefaultDescription
name*string—Result key — the value appears at values[name] in the form's onSubmit
placeholderstring—Text shown inside the native field when empty
defaultValuestring''Initial text
fontTextFont'mojangles'Font family for the typed value and placeholder
scalenumber1.0Scale multiplier relative to the standard glyph size
textOffsetX / textOffsetYnumber8 / vertically centeredTyped-value position offset (px) from the box's left-middle frame
placeholderOffsetX / placeholderOffsetYnumber8 / vertically centeredPlaceholder position offset (px), same frame as the typed value

The box uses background/backgroundHover/backgroundPressed/backgroundLocked for per-state texturing — the same shape as Button; backgroundPressed doubles as the focused-field state.

Inherits control props.

Examples​

Basic input​

<Input name={'nickname'} placeholder={'§7type here'} />

Two inputs side by side​

<Panel flexDirection={'row'} gap={4}>
<Input name={'first'} placeholder={'§7first'} flex={1} />
<Input name={'second'} placeholder={'§7second'} flex={1} />
</Panel>

Notes​

  • Always provide a placeholder — it's the only hint the player gets about what to type.
  • Keep name stable across renders; it's the only key you get back on submit.
  • For themed screens, prefer @bedrock-core/ore-styled's Input over styling this primitive by hand.

Limits​

Modal-only. The engine draws no text field on an action form or a container screen, so writing one there is a build error naming the fix rather than a control drawn inert. <Toggle> and <Select> are the controls that serve all three hosts.