ChevronToArrow
A chevron that turns into an arrow while its link or button is hovered or focused from the keyboard. For a chevron that doesn't animate, use the static chevron icon.
Installation
bun add @harmo-ui/css @harmo-ui/reactnpm install @harmo-ui/css @harmo-ui/reactpnpm add @harmo-ui/css @harmo-ui/reactyarn add @harmo-ui/css @harmo-ui/reactbunx harmo-ui add chevron-to-arrownpx harmo-ui add chevron-to-arrowpnpm dlx harmo-ui add chevron-to-arrowyarn dlx harmo-ui add chevron-to-arrowUsage
import { Button, ChevronToArrow } from "@harmo-ui/react";
<Button>
Continue
<ChevronToArrow />
</Button>Examples
Forward and back
It rests as a chevron and turns into an arrow while its button or link is hovered or focused from the keyboard. Forward is the default; data-direction="back" mirrors it. A back arrow leads the label and a forward arrow follows it.
<>
<Button variant="secondary">
<ChevronToArrow direction="back" />
Go back
</Button>
<Button>
Continue
<ChevronToArrow />
</Button>
</>In a link
Any enabled <a href> or <button> works: hovering anywhere on it reveals the arrow.
<Link href="/blog/automations">
Read the story
<ChevronToArrow />
</Link><a class="hlink" href="/blog/automations">
Read the story
<svg class="hicon hchevron-to-arrow" width="24" height="24" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<g class="hchevron-to-arrow-head">
<line class="hchevron-to-arrow-upper" x1="12" y1="6" x2="12" y2="12" />
<line class="hchevron-to-arrow-lower" x1="12" y1="18" x2="12" y2="12" />
</g>
<line class="hchevron-to-arrow-shaft" x1="6" y1="12" x2="15" y2="12" />
</svg>
</a>Right to left
In right-to-left text both directions mirror again: back always points toward the start of the line, here right, and forward toward its end.
<>
<Button variant="secondary">
<ChevronToArrow direction="back" />
رجوع
</Button>
<Button>
متابعة
<ChevronToArrow />
</Button>
</>Without animation
In a disabled control it shows the finished arrow and doesn't move, as it does on touch screens and with reduced motion.
<Button disabled>
Continue
<ChevronToArrow />
</Button><button class="hbutton" type="button" disabled>
<span class="hbutton-label">Continue</span>
<svg class="hicon hchevron-to-arrow" width="24" height="24" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<g class="hchevron-to-arrow-head">
<line class="hchevron-to-arrow-upper" x1="12" y1="6" x2="12" y2="12" />
<line class="hchevron-to-arrow-lower" x1="12" y1="18" x2="12" y2="12" />
</g>
<line class="hchevron-to-arrow-shaft" x1="6" y1="12" x2="15" y2="12" />
</svg>
</button>API reference
React
<ChevronToArrow> draws the SVG. Put it in a <Button> or <Link>, before the text for back and after it for forward. Other props are the <svg>'s attributes.
| Prop | Effect |
|---|---|
direction | back mirrors it; forward when left out |
HTML
An <svg class="hicon hchevron-to-arrow" viewBox="0 0 24 24"> inside an enabled <a href> or <button>, with aria-hidden="true" and focusable="false". It holds a .hchevron-to-arrow-head, with .hchevron-to-arrow-upper and .hchevron-to-arrow-lower, and a .hchevron-to-arrow-shaft: the head group slides, and the shaft fades in. Load chevron-to-arrow.css. It needs no script.
| Hook | Effect |
|---|---|
| (default) | Points forward |
data-direction="back" | Points back, such as for "Go back" |
Back mirrors the whole drawing, so both directions draw and animate the same way. In right-to-left text both mirror again: back points toward the start of the line, forward toward its end. See ChevronToArrow's full contract.
Accessibility
Decorative: aria-hidden="true", with the link's or button's text naming it.