Build a TransferList component: two lists side by side with a column of buttons between them, used to move items from one list to the other. You have probably seen one when picking which columns to show in a table, or which permissions to grant a role.
<TransferList initialLeft={["HTML", "CSS", "JavaScript"]} initialRight={["React"]} />
Props:
initialLeft: the items that start in the left list. Defaults to [].initialRight: the items that start in the right list. Defaults to [].Items are unique strings. After the first render the component owns its own state.
Layout and markup:
<fieldset> with the <legend> Available. The right list is a <fieldset> with the <legend> Selected.<label><input type="checkbox" /> CSS</label>.No items instead.The four buttons, from top to bottom:
| Button | aria-label | What it does |
|---|---|---|
» | Move all to Selected | Moves every item in Available to Selected. |
› | Move checked to Selected | Moves only the checked items in Available to Selected. |
‹ | Move checked to Available | Moves only the checked items in Selected to Available. |
« | Move all to Available | Moves every item in Selected to Available. |
Rules:
Start with Available HTML, CSS, JavaScript, React and Selected Vue.
React, then HTML, and press ›. Available is now CSS, JavaScript and Selected is Vue, HTML, React, with nothing checked.«. Available is now CSS, JavaScript, Vue, HTML, React and Selected shows No items. Both buttons that move items to Available are now disabled.<TransferList initialLeft={["HTML", "CSS", "JavaScript"]} initialRight={["React"]} />