Components / Inputs
TransferList
Move items between two lists, e.g. which products earn stamps.
import { TransferList } from "@stylhero/ui";
Example
Code
import { TransferList } from "@stylhero/ui";
function TransferListExample() {
return (
<TransferList titles={["Available", "In your build"]} defaultValue={["ssd"]}
items={[{ value: "cpu", label: "CPU" }, { value: "gpu", label: "GPU" }, { value: "ssd", label: "SSD" }, { value: "psu", label: "Power supply" }]} />
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items required |
TransferItem[] |
- | Every item; the ones in value show on the right. |
defaultValue |
string[] |
[] |
|
onValueChange |
(value: string[]) => void |
- | |
titles |
[ReactNode, ReactNode] |
["Available", "Chosen"] |
|
value |
string[] |
- |
Also takes every <div> attribute (id, style, data-*, aria-*, event handlers…), passed to that element.
Types
type TransferItem = { value: string; label: ReactNode };
Keyboard
| Key | Does |
|---|---|
| Space | Checks an item |
| Tab | Moves to the buttons that move checked items across |
Accessibility
- Each list and button is labelled, e.g. "Move selected right".
Generated from src/components/TransferList.tsx. Something wrong or missing? Open an issue.