mirror of
https://github.com/zhigang1992/react-native-hold-menu.git
synced 2026-06-15 10:28:07 +08:00
159 lines
2.9 KiB
Markdown
159 lines
2.9 KiB
Markdown
---
|
|
id: examples
|
|
title: Examples
|
|
slug: /examples
|
|
---
|
|
|
|
:::info
|
|
If you want to see full examples in your phone or simulator, you can clone [this showcase project](https://github.com/enesozturk/react-native-hold-menu-expo-example) and run in seconds with Expo 🔥
|
|
:::
|
|
|
|
## Configuring List
|
|
|
|
### Sample List
|
|
|
|
**Code**
|
|
|
|
```js
|
|
<HoldItem
|
|
items={[
|
|
{ text: 'Reply', onPress: () => {} },
|
|
{ text: 'Edit', onPress: () => {} },
|
|
{ text: 'Delete', onPress: () => {} },
|
|
]}
|
|
/>
|
|
```
|
|
|
|
**Result**
|
|
|
|

|
|
|
|
### List with title
|
|
|
|
**Code**
|
|
|
|
```js
|
|
<HoldItem
|
|
items={[
|
|
{ text: 'Actions', isTitle: true, onPress: () => {} },
|
|
{ text: 'Reply', onPress: () => {} },
|
|
{ text: 'Edit', onPress: () => {} },
|
|
{ text: 'Delete', onPress: () => {} },
|
|
]}
|
|
/>
|
|
```
|
|
|
|
**Result**
|
|
|
|

|
|
|
|
### List with seperator
|
|
|
|
**Code**
|
|
|
|
```js
|
|
<HoldItem
|
|
items={[
|
|
{ text: 'Actions', isTitle: true, onPress: () => {} },
|
|
{ text: 'Reply', onPress: () => {} },
|
|
{ text: 'Edit', onPress: () => {} },
|
|
{ text: 'Delete', withSeperator: true, onPress: () => {} },
|
|
{ text: 'Share', onPress: () => {} },
|
|
]}
|
|
/>
|
|
```
|
|
|
|
**Result**
|
|
|
|

|
|
|
|
### List with destructive button
|
|
|
|
**Code**
|
|
|
|
```js
|
|
<HoldItem
|
|
items={[
|
|
{ text: 'Actions', isTitle: true, onPress: () => {} },
|
|
{ text: 'Reply', onPress: () => {} },
|
|
{ text: 'Edit', onPress: () => {} },
|
|
{
|
|
text: 'Delete',
|
|
withSeperator: true,
|
|
isDestructive: true,
|
|
onPress: () => {},
|
|
},
|
|
{ text: 'Share', onPress: () => {} },
|
|
]}
|
|
/>
|
|
```
|
|
|
|
**Result**
|
|
|
|

|
|
|
|
### List with icons
|
|
|
|
**Code**
|
|
|
|
```js
|
|
<HoldItem
|
|
items={[
|
|
{ text: 'Action', isTitle: true, onPress: () => {} },
|
|
{
|
|
text: 'Home',
|
|
icon: () => <Icon name="home" size={18} />,
|
|
onPress: () => {},
|
|
},
|
|
{
|
|
text: 'Edit',
|
|
icon: () => <Icon name="edit" size={18} />,
|
|
onPress: () => {},
|
|
},
|
|
{
|
|
text: 'Delete',
|
|
icon: () => <Icon name="delete" size={18} />,
|
|
withSeperator: true,
|
|
isDestructive: true,
|
|
onPress: () => {},
|
|
},
|
|
{
|
|
text: 'Share',
|
|
icon: () => <Icon name="share" size={18} />,
|
|
onPress: () => {},
|
|
},
|
|
{
|
|
text: 'More',
|
|
icon: () => <Icon name="more-horizontal" size={18} />,
|
|
onPress: () => {},
|
|
},
|
|
]}
|
|
/>
|
|
```
|
|
|
|
**Result**
|
|
|
|

|
|
|
|
<!-- ## Configuring Hold Item -->
|
|
|
|
<!-- ## Menu from bottom
|
|
|
|
**Code**
|
|
|
|
```js
|
|
<HoldItem
|
|
bottom
|
|
items={[
|
|
{ text: 'Action', isTitle: true, onPress: () => {} },
|
|
{ text: 'Action 1', onPress: () => {} },
|
|
{ text: 'Action 2', withSeperator: true, onPress: () => {} },
|
|
{ text: 'Action 3', isDestructive: true, onPress: () => {} },
|
|
]}
|
|
/>
|
|
```
|
|
|
|
**Result**
|
|
|
|
 -->
|