Skip to content

Commit f5b6403

Browse files
Document Snaps Card Component (#1707)
* Document Snaps Card Component This closes #1593 Also updates What's New to include Card and Section components. * Add PRs and fix links in What's New * Update image sizing for Card example * Add an info section for Card and reorder the params. * Update docs/whats-new.md --------- Co-authored-by: Alexandra Carrillo <[email protected]>
1 parent 32f7690 commit f5b6403

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

docs/whats-new.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ The latest major MetaMask documentation updates are listed by the month they wer
99
For a comprehensive list of recent product changes, visit the "Release Notes" section at the bottom
1010
of the [MetaMask developer page](https://metamask.io/developer/).
1111

12+
## November 2024
13+
14+
- Documented Snaps [`Card`](/snaps/features/custom-ui/#card) and [`Section`](/snaps/features/custom-ui/#section) UI components.
15+
([#1707](https://github.com/MetaMask/metamask-docs/pull/1707)) ([#1700](https://github.com/MetaMask/metamask-docs/pull/1700))
16+
1217
## October 2024
1318

1419
- Documented support for [non-EVM networks](/wallet/how-to/use-non-evm-networks), starting with [Starknet](/wallet/how-to/use-non-evm-networks/starknet). ([#1509](https://github.com/MetaMask/metamask-docs/pull/1509))

snaps/assets/custom-ui-card.png

29 KB
Loading

snaps/features/custom-ui/index.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,66 @@ await snap.request({
203203
<img src={require("../../assets/custom-ui-button.png").default} alt="Button UI example" width="450px" style={{border: "1px solid #DCDCDC"}} />
204204
</p>
205205
206+
### `Card`
207+
208+
Outputs a card component which is used to display values in a card structure.
209+
210+
:::info
211+
Unlike many `Card` components from other UI libraries, the Snaps `Card` does not have any shape.
212+
It is only used for layout. To give a shape to a `Card`, wrap it in a [`Section`](#section) component.
213+
:::
214+
215+
#### Props
216+
217+
- `title`: `string` - The title of the card.
218+
- `value`: `string` - The value, shown on the right side.
219+
- `image`: `string` - (Optional) An image shown on the left side. Accepts inline SVG.
220+
- `description`: `string` - (Optional) A description, shown below the title.
221+
- `extra`: `string` - (Optional) Additional text shown below the value.
222+
223+
#### Example
224+
225+
```js
226+
import icon from "./../img/icon.svg"
227+
228+
export const onHomePage: OnHomePageHandler = async () => {
229+
return {
230+
content: (
231+
<Box>
232+
<Card
233+
image={icon}
234+
title="Card title"
235+
description="Card description"
236+
value="Card value"
237+
extra="Extra value"
238+
/>
239+
<Card
240+
title="Minimal card"
241+
value="Example value"
242+
/>
243+
<Section>
244+
<Card
245+
image={icon}
246+
title="Card title"
247+
description="Card description"
248+
value="Card value"
249+
extra="Extra value"
250+
/>
251+
<Card
252+
title="Minimal card"
253+
value="Example value"
254+
/>
255+
</Section>
256+
</Box>
257+
),
258+
};
259+
};
260+
```
261+
262+
<p align="center">
263+
<img src={require("../../assets/custom-ui-card.png").default} alt="Card UI example" width="450px" style={{border: "1px solid #DCDCDC"}} />
264+
</p>
265+
206266
### `Checkbox`
207267
208268
Outputs a checkbox for use in [interactive UI](interactive-ui.md).

0 commit comments

Comments
 (0)