PlaceholderMarquee
HkPlaceholderMarquee is the overflow strategy for a placeholder that does not fit its input. In marquee mode the overlay stays in the DOM as an invisible measuring probe while the text fits, and the host input shows its native placeholder; once the text overflows, the overlay becomes visible, renders the text three times side by side inside a clipping window and translates the strip in a loop. truncate mode hard-cuts the text at the container edge instead.
There is no Rust mirror of this component; it is Vue-only.
- A token budget with a unit picker is HkTokenInput; a tag field is HkTagInput.
- A currency amount is HkMoneyInput.
Import
;
The component renders the overlay only; the host owns the input, listens for overflowChange, and swaps its native placeholder for this overlay at that edge.
Marquee and truncate
variant="marquee" (the default) scrolls the overflow; variant="truncate" ellipsises it. text is the placeholder string, and an empty text renders nothing at all.
Speed and direction
speed is the strip's travel in pixels per second and defaults to 24. A negative speed scrolls rightward (the loop plays in reverse), and a zero speed parks the strip as static text — as does a non-finite speed, which falls back to the default rate. The motion is pure CSS: one registered infinite keyframes animation whose loop distance and duration live on inline custom properties, measured once per geometry change rather than per frame.
Hosting it in an input
The overlay reacts to geometry, not to typing: a ResizeObserver on the host element re-measures on every size change, and text changes re-measure after the next paint. The overlay's own edge sits half a pixel past the host — the epsilon keeps an exact fit static — and it exposes setActive(active) so the host parks the strip while its input is focused, and measure() to force a pass. The overlay is aria-hidden, so it never competes with the input's own accessible name.
API
Vue
Props
| Name | Type | Default | Required |
|---|---|---|---|
| text | String | "" | — |
| variant | String as PropType<PlaceholderVariant> | "marquee" | — |
| speed | Number | 24 | — |
Emits
| Event | Payload |
|---|---|
| overflowChange | boolean |
Accessibility
- The overlay is aria-hidden="true": the placeholder overlays text, it never becomes the field's name or description.
- The scrolling strip is a visual affordance only; a pointer or keyboard user reads the field's placeholder / aria-label exactly as before.
- The animation lives on the compositor and the component parks it while the host input is focused, so it does not run under an active caret; the animation-context switch (html[data-css-animations="0"] and reduced motion) parks it as well.
Related components
- HkMoneyInput — a currency amount over canonical decimal text.
- HkTokenInput — a token budget with a unit picker.
- HkTagInput — an ordered tag field with a searchable catalog.
- HkTemplateField — the editor for {{ token }} fill templates.