Skip to main content

Dropdown

Select field with a popup inside a Form or Experimental_OreUI screen. Pressing it opens a scrollable list of Option children.

Import​

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

Usage​

<Form onSubmit={v => console.warn(v.mode)}>
<Dropdown name={'mode'} defaultValue={'Normal'}>
<Option value={'Easy'} label={'Easy'} />
<Option value={'Normal'} label={'Normal'} />
<Option value={'Hard'} label={'Hard'} />
</Dropdown>
<Form.Button type={'submit'}>{'Save'}</Form.Button>
</Form>
Modal and live results

Inside Form, Dropdown reports the selected option's index at values[name] on submit. Inside Experimental_OreUI, onChange receives the selected option's string value.

Props​

PropTypeDefaultDescription
namestring—Required result key inside Form; optional on an Ore screen
valuestringinternal stateControlled option value on an Ore screen
onChange(value: string, event: UiEvent) => void | Promise<void>—Receives the selected Ore option value and the owning player's event
defaultValuestringthe first optionInitial selection, matched against a Option's value
childrenJSX.Node—The selectable options, authored as Option elements. Popup rows flow at a fixed row height, so an option's own layout props are ignored here — only its value/label/style are read
popupBackgroundstringthe unstyled placeholder textureBackground texture for the popup surface behind the option list
optionBackground / optionHover / optionSelectedstring—Group-level default row textures for idle/hover/selected states. Any Option can override its own
optionFont / optionScale / optionAlignTextFont / number / 'left' | 'center' | 'right''mojangles' / 1.0 / 'left'Group-level default label styling for option rows. Any Option can override its own
currentColorstring''Color code prefix (e.g. '§0') applied to the closed-box current-value text
currentFont / currentScaleTextFont / number'mojangles' / 1.0Font and scale for the closed-box current-value label
currentInsetX / currentInsetYnumber8 / vertically centeredPosition offset (px) of the current-value label from the closed box's left-middle frame

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

Inherits control props.

Examples​

Basic dropdown​

<Dropdown name={'mode'} defaultValue={'Normal'}>
<Option value={'Easy'} label={'Easy'} />
<Option value={'Normal'} label={'Normal'} />
<Option value={'Hard'} label={'Hard'} />
</Dropdown>

Per-option alignment override​

The group sets a default alignment for all options; any option can override its own.

<Dropdown name={'m_dd1'} defaultValue={'Two'} optionAlign={'center'}>
<Option value={'One'} label={'One'} />
<Option value={'Two'} label={'Two'} />
<Option value={'Three'} label={'Three'} align={'right'} />
</Dropdown>

Reading the result​

const options = ['Easy', 'Normal', 'Hard'];

<Form onSubmit={v => {
const selected = options[v.mode as number];
console.warn(selected);
}}>
<Dropdown name={'mode'} defaultValue={'Normal'}>
{options.map(o => <Option key={o} value={o} label={o} />)}
</Dropdown>
<Form.Button type={'submit'}>{'Save'}</Form.Button>
</Form>

Notes​

  • Inside Form, keep Option children order stable across renders; the submitted result is an index.
  • Read Form's values[name] as an index and map it back to your own array when you need the option value. Ore's live onChange receives the option value directly.
  • Prefer Select instead when you want every option visible without an extra tap (e.g. a short radio-style choice).
  • For themed screens, prefer @bedrock-core/ore-styled's Dropdown over styling this primitive by hand.

Limits​

Supported inside Form and Experimental_OreUI. Action forms and container screens refuse dropdown fields at build time. Keep option values and the compiled option structure stable on an Ore screen.