Dropdown
Select field with a chevron. Pressing it opens a modal to choose one of a fixed set of options. Supports controlled and uncontrolled usage.
Import
import { Dropdown } from '@bedrock-core/ore-styled';
Usage
<Dropdown
label={'Difficulty'}
options={['Peaceful', 'Easy', 'Normal', 'Hard']}
defaultValue={'Normal'}
onChange={(value) => console.log(value)}
/>
Built on top of the Dropdown primitive and the theme token map. The current selection sits on the left with a chevron on the right, inside the Ore-UI field frame; pressing it opens a single-dropdown modal — confirm commits the choice, cancel keeps the current one.
Props
Component-Specific Props
options (required)
- Type:
string[] - Description: The selectable options. The face shows the current one; the modal lists them all.
value
- Type:
string - Description: Controlled selection — should match one of
options. When provided, the face reflects it on every render andonChangeis your only way to update it.
defaultValue
- Type:
string - Default: the first option
- Description: Initial selection when running uncontrolled.
onChange
- Type:
(value: string, index: number) => void - Description: Called with the chosen option and its index in
optionswhen the player confirms the modal.
onCancel
- Type:
() => void - Description: Called when the player cancels (X / Esc) the modal. The selection is left unchanged.
Modal Field Props
Dropdown inherits all modal field props (label, title, body, submitLabel, tooltip) for configuring the modal.
Control Props
Dropdown inherits all standard control props. Use enabled={false} to render the disabled texture (including a dimmed chevron) and make the field inert (no modal opens).
Examples
Controlled
function DifficultySetting() {
const [difficulty, setDifficulty] = useState('Normal');
return (
<Panel flexDirection={'column'} gap={6}>
<Dropdown
width={160}
label={'Difficulty'}
options={['Peaceful', 'Easy', 'Normal', 'Hard']}
value={difficulty}
onChange={setDifficulty}
title={'Select difficulty'}
submitLabel={'Save'}
/>
<Text>{`Selected: ${difficulty}`}</Text>
</Panel>
);
}
Uncontrolled
<Dropdown
options={['Red', 'Green', 'Blue']}
onChange={(value, index) => console.log(index, value)}
/>
Best Practices
- Keep
optionsstable across renders; deriving it inline from changing data can shift indices unexpectedly. - A controlled
valueshould always be one ofoptions— an unknown value falls back to the first option on the face. - For two-state choices use a
Toggleinstead of a two-item dropdown.