HkSelect is the dropdown choice field: a caption, a trigger button that shows the chosen option's label (or the placeholder while nothing is picked) and a chevron, and — once opened — the option list. On a desktop the list is an anchored popout; below 768px it becomes a bottom sheet instead. Reach for it when one value comes out of a fixed, ordered list and the full set is too long to show at once.
A handful of options that all fit on the page are better as one control each: HkRadio for one pick, HkCheckbox for many.
An on/off decision is a HkSwitch, and a value on a continuous track is a HkSlider — both say their state without opening a surface.
A filter field that narrows a list as you type is an HkSearchInput.
The Rust form is a plain function, Select(SelectProps { … }). Every prop may be omitted inside rsx!, and an omitted prop takes its default. The Vue form is controlled (modelValue + update:modelValue); the Rust form is a still, so its examples pass the value the field holds. Both forms keep the disclosure state — and, in Rust, the highlighted row — outside the component; see Opening and highlighting.
Options and states
options is the list: each entry carries a value (what gets emitted), a label (what the row and the trigger read) and an optional disabled. The trigger shows the label of the option matching modelValue; when nothing matches, the raw value is shown, and while modelValue is empty the placeholder stands in. label draws the caption, required appends the * marker, error turns the trigger red and prints a line under it, and disabled greys the whole field and takes it out of the tab order.
The panel is not in the snapshot: a screenshot of this page shows every stage below with its trigger only, closed. The first stage of the next section shows the opened popout instead — a still cannot press a button, so that example presses the trigger itself once the field has mounted.
This language is not enabled for the project.
This language is not enabled for the project.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import{HkSelect}from"@celestia-island/hikari";importtype{CSSProperties}from"vue";constcolumn: CSSProperties={display:"grid",gap:"16px",maxWidth:"320px"};constoptions=[{value:"ts",label:"TypeScript"},{value:"rust",label:"Rust"},{value:"go",label:"Go",disabled:true},];exportdefault()=>(<divstyle={column}><HkSelectlabel="Language"requiredoptions={options}modelValue="rust"/><HkSelectlabel="Language"options={options}placeholder="Pick a language"/><HkSelectlabel="Language"options={options}modelValue="go"error="This language is not enabled for the project."/><HkSelectlabel="Language"options={options}modelValue="rust"disabled/></div>
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
rsx!{
div { style:"display:grid;gap:16px;max-width:320px",
Select {
label:Some("Language".to_string()),
required:true,
model_value:"rust".to_string(),
options:vec![
SelectOption {
value:"ts".to_string(),
label:"TypeScript".to_string(),..Default::default()},
SelectOption {
value:"rust".to_string(),
label:"Rust".to_string(),..Default::default()},
SelectOption {
value:"go".to_string(),
label:"Go".to_string(),
disabled:true,},],}
Select {
label:Some("Language".to_string()),
placeholder:"Pick a language".to_string(),
options:vec![SelectOption {
value:"ts".to_string(),
label:"TypeScript".to_string(),..Default::default()}],}
Select {
label:Some("Language".to_string()),
model_value:"go".to_string(),
error:Some("This language is not enabled for the project.".to_string()),
options:vec![SelectOption {
value:"go".to_string(),
label:"Go".to_string(),
disabled:true,}],}
Select {
label:Some("Language".to_string()),
model_value:"rust".to_string(),
disabled:true,
options:vec![SelectOption {
value:"rust".to_string(),
label:"Rust".to_string(),..Default::default()}],}}}
Pressing the trigger toggles the surface. On a desktop it is a popout anchored to the trigger, with placement deciding the side and the alignment — bottom-start (the default), bottom-center, bottom-end, top-start, top-center, top-end — and it grows upward for the top-* values, which is what a field pinned to the bottom of the viewport needs. Below 768px the same list docks as a bottom sheet with a grabber, a title and a ✕, whatever placement says. panelTitle names the opened surface without drawing a caption on the field itself, so a field labelled by a titled row around it still registers the surface with a name.
The Vue example presses its own trigger after mounting, which is the only way a still can show the opened panel: the popout is anchored to the field, lists the same options with the current one marked, and every row is a plain div — pressing the trigger on the live page toggles the surface.
Active
Paused
Archived
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import{defineComponent,typeVNode}from"vue";import{HkSelect}from"@celestia-island/hikari";importtype{CSSProperties}from"vue";constcolumn: CSSProperties={display:"grid",gap:"16px",maxWidth:"320px"};constoptions=[{value:"active",label:"Active"},{value:"paused",label:"Paused"},{value:"archived",label:"Archived"},];exportdefaultdefineComponent({setup(){// HkSelect keeps its disclosure state in a local ref and takes no `open`
// prop, so a snapshot of the opened panel is taken by pressing the
// trigger once, after the field mounts.
constopenOnMount=(vnode: VNode)=>{constroot=vnode.elasHTMLElement|null;consttrigger=root?.querySelector(".hk-select-trigger");(triggerasHTMLButtonElement|null)?.click();};return()=>(<divstyle={column}><HkSelectlabel="Status"options={options}modelValue="paused"placement="bottom-start"onVnodeMounted={openOnMount}/><HkSelectlabel="Sort by"options={options}placeholder="Not sorted"panelTitle="Sort the result by"placement="top-start"/></div>
);
},
});
The disclosure is internal to Vue: the component owns isOpen, and pressing the trigger flips it. The Rust mirror has no per-instance state to hold, so there the same flag is a prop pair — open + on_open_change, which reports the requested state for a trigger press, a row commit, Escape or a click outside the field, and the host writes it back. A Vue caller reads the chosen value from update:modelValue; it does not need to bind open.
Highlighting is a second pair, and it is the one real difference between the two forms. Vue keeps highlightedIndex in a local ref, seeds it with the current selection when the panel opens, and moves it with the arrow keys and the pointer. The Rust mirror has no per-instance state to hold, so the index is highlighted_index + on_highlight_change: the host stores it and passes it back, and the rows draw their data-highlighted from whatever the host last recorded. On a desktop popout the rows also report a pointer hover through the same channel.
Picked so far: none
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import{defineComponent,ref,watch,typeVNode}from"vue";import{HkSelect}from"@celestia-island/hikari";importtype{CSSProperties}from"vue";constcolumn: CSSProperties={display:"grid",gap:"16px",maxWidth:"320px"};constoptions=[{value:"draft",label:"Draft"},{value:"review",label:"In review"},{value:"live",label:"Live"},];exportdefaultdefineComponent({setup(){conststage=ref("live");constpicked=ref<string[]>([]);watch(stage,(value)=>picked.value.push(value));// The same one-press mount hook: the panel has to be open for the
// controlled `update:modelValue` to be observable in a still.
constopenOnce=(vnode: VNode)=>{constroot=vnode.elasHTMLElement|null;consttrigger=root?.querySelector(".hk-select-trigger");(triggerasHTMLButtonElement|null)?.click();};return()=>(<divstyle={column}><HkSelectlabel="Stage"options={options}modelValue={stage.value}onUpdate:modelValue={(value:string) => {
stage.value = value;
}}
onVnodeMounted={openOnce}/><p>Pickedsofar: {picked.value.length === 0 ? "none":picked.value.join(" → ")}</p>
</div>);
},
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// The three controlled values the field reports back: the open flag, the
// highlighted row and the chosen value. Each callback owns its own handle,
// so every one is cloned before it moves into the closure.
let stage_open =use_signal(||false);let stage_highlight =use_signal(||1_i32);let stage_value =use_signal(||"live".to_string());let open_sink = stage_open.clone();let open_close_sink = stage_open.clone();let highlight_sink = stage_highlight.clone();let value_sink = stage_value.clone();rsx!{
Select {
label:Some("Stage".to_string()),
model_value: stage_value.read(),
open: stage_open.read(),
highlighted_index: stage_highlight.read(),
on_open_change:Some(event_handler(move|open:bool| open_sink.set(open))),
on_highlight_change:Some(event_handler(move|index:i32| highlight_sink.set(index))),
on_value_change:Some(event_handler(move|value:String|{
value_sink.set(value);
open_close_sink.set(false);})),
options:vec![
SelectOption {
value:"draft".to_string(),
label:"Draft".to_string(),..Default::default()},
SelectOption {
value:"review".to_string(),
label:"In review".to_string(),..Default::default()},
SelectOption {
value:"live".to_string(),
label:"Live".to_string(),..Default::default()},],}}
import { defineComponent, ref, watch, type VNode } from "vue";
import { HkSelect } from "@celestia-island/hikari";
import type { CSSProperties } from "vue";
const column: CSSProperties = { display: "grid", gap: "16px", maxWidth: "320px" };
const options = [
{ value: "draft", label: "Draft" },
{ value: "review", label: "In review" },
{ value: "live", label: "Live" },
];
export default defineComponent({
setup() {
const stage = ref("live");
const picked = ref<string[]>([]);
watch(stage, (value) => picked.value.push(value));
// The same one-press mount hook: the panel has to be open for the
// controlled `update:modelValue` to be observable in a still.
const openOnce = (vnode: VNode) => {
const root = vnode.el as HTMLElement | null;
const trigger = root?.querySelector(".hk-select-trigger");
(trigger as HTMLButtonElement | null)?.click();
};
return () => (
<div style={column}>
<HkSelect
label="Stage"
options={options}
modelValue={stage.value}
onUpdate:modelValue={(value: string) => {
stage.value = value;
}}
onVnodeMounted={openOnce}
/>
<p>Picked so far: {picked.value.length === 0 ? "none" : picked.value.join(" → ")}</p>
</div>
);
},
});
// The three controlled values the field reports back: the open flag, the
// highlighted row and the chosen value. Each callback owns its own handle,
// so every one is cloned before it moves into the closure.
let stage_open = use_signal(|| false);
let stage_highlight = use_signal(|| 1_i32);
let stage_value = use_signal(|| "live".to_string());
let open_sink = stage_open.clone();
let open_close_sink = stage_open.clone();
let highlight_sink = stage_highlight.clone();
let value_sink = stage_value.clone();
rsx! {
Select {
label: Some("Stage".to_string()),
model_value: stage_value.read(),
open: stage_open.read(),
highlighted_index: stage_highlight.read(),
on_open_change: Some(event_handler(move |open: bool| open_sink.set(open))),
on_highlight_change: Some(event_handler(move |index: i32| highlight_sink.set(index))),
on_value_change: Some(event_handler(move |value: String| {
value_sink.set(value);
open_close_sink.set(false);
})),
options: vec![
SelectOption {
value: "draft".to_string(),
label: "Draft".to_string(),
..Default::default()
},
SelectOption {
value: "review".to_string(),
label: "In review".to_string(),
..Default::default()
},
SelectOption {
value: "live".to_string(),
label: "Live".to_string(),
..Default::default()
},
],
}
}
API
Vue
Props
Name
Type
Default
Required
modelValue
String
""
—
label
String
undefined
—
panelTitle
String
undefined
—
placeholder
String
""
—
error
String
undefined
—
disabled
Boolean
false
—
required
Boolean
false
—
options
Array as PropType<HkSelectOption[]>
() => [] as HkSelectOption[]
—
placement
String as PropType<SelectPanelPlacement>
"bottom-start"
—
aboveChrome
Boolean
false
—
Emits
Event
Payload
update:modelValue
string
Rust
Props — Select
Prop
Type
Default
Description
model_value
String
""
Vue: modelValue, default "".
label
Option<String>
None
Visible caption above the trigger (Vue: label).
panel_title
Option<String>
None
Title for the OPENED surface only (mobile sheet heading, popout a11y name).
placeholder
String
""
Shown while the model is empty (Vue default "").
error
Option<String>
None
Error ink + message line (data-error on the trigger).
disabled
bool
false
—
required
bool
false
Appends the * marker to the caption (Vue: required).
Keyboard/pointer highlight index; -1 means "none" (Vue: the local highlightedIndex).
sheet_on_mobile
bool
true
Dock as a bottom sheet below 768px (Vue panel default: true).
offset
f64
4.0
Gap between the trigger and the popout, in px (Vue panel default 4).
match_anchor_width
bool
true
Tie the popout's minimum width to the trigger (Vue panel default true).
anchor
Option<SelectAnchorRect>
None
The trigger rect to anchor against.
max_height
Option<String>
None
Cap for the DESKTOP POPOUT, as any CSS length (Vue panel maxHeight, published through --hk-select-panel-max-height on the popout only).
class
String
""
—
on_open_change
Option<EventHandler<bool>>
None
Fires with the desired open state (Vue: update:open).
on_value_change
Option<EventHandler<String>>
None
Fires with the chosen option value (Vue: update:modelValue).
on_highlight_change
Option<EventHandler<i32>>
None
Fires with the desired highlight index (the Rust-side stand-in for Vue's local highlightedIndex writes).
native
bool
false
Render a native <select> instead of the mirrored trigger and popout: the platform's own menu, keyboard and mobile picker, one <option> per option, and none of the sheet's classes — class and attrs land on the element.
attrs
Vec<(String, String)>
[]
Attributes set on the native <select> by name — name, title, data-*, aria-*, test hooks.
Accessibility
The trigger is a real <button type="button">: Enter and Space open the field, the arrow keys step the highlight and Enter commits the highlighted row — a disabled row silently refuses the commit.
Escape closes the open panel and stops propagating, so one press never closes both the dropdown and the dialog it sits in. A closed field lets Escape through to its host.
required is drawn as the * marker on the caption, not as the aria-required attribute; pass the requirement in the surrounding copy as well if assistive technology must hear it.
The caption is a plain <label> with no for in either form, and the trigger carries no aria-labelledby. Keep the field's name short and repeat it in the surface title (panelTitle) when the field's own caption lives in a row header.
The opened surface carries aria-label from panelTitle (or label); the mobile sheet is a role="dialog" with aria-modal, so a screen reader announces the list, not the trigger's state.
A row is not a native control: read out its state through the labels you pass, not through selection affordances.
Related components
HkRadio — one pick from a short list, all options visible.
HkCheckbox — several picks that do not need a surface.