Skip to content

Commit 053070f

Browse files
committed
Document Selector component
1 parent d112cef commit 053070f

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

snaps/assets/custom-ui-selector.png

31.5 KB
Loading

snaps/features/custom-ui/with-jsx.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,43 @@ await snap.request({
660660
<img src={require("../../assets/custom-ui-row.png").default} alt="Row UI example" width="450px" style={{border: "1px solid #DCDCDC"}} />
661661
</p>
662662

663+
### `Selector`
664+
665+
Outputs a selector component for use in [interactive UI](interactive-ui.md).
666+
667+
#### Props
668+
669+
- `name`: `string` - The name that will be used as a key to the event sent to
670+
[`onUserInput`](../../reference/entry-points.md#onuserinput) when the containing form is submitted.
671+
- `title`: `string` - The title of the selector, displayed when the selector is opened.
672+
- `children`: `SelectorOption[]` - One or more `SelectorOption` components, each with a `Card` child (see example).
673+
674+
#### Example
675+
676+
```js
677+
import { Selector, SelectorOption, Card } from "@metamask/snaps-sdk/jsx";
678+
679+
const interfaceId = await snap.request({
680+
method: "snap_createInterface",
681+
params: {
682+
ui: (
683+
<Selector name="selector-example" title="Select an option">
684+
<SelectorOption value="option-1">
685+
<Card title="Option 1" value="First option" />
686+
</SelectorOption>
687+
<SelectorOption value="option-2">
688+
<Card title="Option 2" value="Second option" />
689+
</SelectorOption>
690+
</Selector>
691+
),
692+
},
693+
});
694+
```
695+
696+
<p align="center">
697+
<img src={require("../../assets/custom-ui-selector.png").default} alt="Selector UI example" width="450px" style={{border: "1px solid #DCDCDC"}} />
698+
</p>
699+
663700
### `Spinner`
664701

665702
Outputs a loading indicator.

0 commit comments

Comments
 (0)