An Action Sheet is a dialog that displays a set of options. It appears on top of the app's content.
NativeBase exports 3 modal-related components:
Actionsheet: Provides the context and state for all components.
Actionsheet.Content: Component to wrap the list of Actionsheet.Item components.
Actionsheet.Item: A button to wrap the options of the Actionsheet.
import { Actionsheet } from "native-base";
function Example() {
const {
isOpen,
onOpen,
onClose
} = useDisclose();
return <>
<Button onPress={onOpen}>Actionsheet</Button>
<Actionsheet isOpen={isOpen} onClose={onClose}>
<Actionsheet.Content>
<Actionsheet.Item>Option 1</Actionsheet.Item>
<Actionsheet.Item>Option 2</Actionsheet.Item>
<Actionsheet.Item>Option 3</Actionsheet.Item>
</Actionsheet.Content>
</Actionsheet>
</>;
}
function Example() {
const {
isOpen,
onOpen,
onClose
} = useDisclose();
return <>
<Button onPress={onOpen}>Actionsheet</Button>
<Actionsheet isOpen={isOpen} onClose={onClose}>
<Actionsheet.Content>
<Divider borderColor="gray.300" />
<Actionsheet.Item _text={{
color: "blue.500"
}}>
Save
</Actionsheet.Item>
<Divider borderColor="gray.300" />
<Actionsheet.Item _text={{
color: "blue.500"
}}>
Delete
</Actionsheet.Item>
</Actionsheet.Content>
</Actionsheet>
</>;
}
function Example() {
const {
isOpen,
onOpen,
onClose
} = useDisclose();
return <>
<Button onPress={onOpen}>Actionsheet</Button>
<Actionsheet isOpen={isOpen} onClose={onClose} disableOverlay>
<Actionsheet.Content>
<Actionsheet.Item>Option 1</Actionsheet.Item>
<Actionsheet.Item>Option 2</Actionsheet.Item>
<Actionsheet.Item>Option 3</Actionsheet.Item>
</Actionsheet.Content>
</Actionsheet>
</>;
}
function Example() {
const {
isOpen,
onOpen,
onClose
} = useDisclose();
return <>
<Button onPress={onOpen}>Actionsheet</Button>
<Actionsheet isOpen={isOpen} onClose={onClose} size="full">
<Actionsheet.Content>
<Actionsheet.Item startIcon={<Icon as={<MaterialIcons name="share" />} color="muted.500" mr={3} />}>
Share
</Actionsheet.Item>
<Actionsheet.Item startIcon={<Icon as={<MaterialCommunityIcons name="link" />} color="muted.500" mr={3} />}>
Link
</Actionsheet.Item>
<Actionsheet.Item startIcon={<Icon as={<MaterialIcons name="edit" />} color="muted.500" mr={3} />}>
Edit name
</Actionsheet.Item>
<Actionsheet.Item startIcon={<Icon as={<MaterialIcons name="delete" />} color="muted.500" mr={3} />}>
Delete Collection
</Actionsheet.Item>
</Actionsheet.Content>
</Actionsheet>
</>;
}
Actionsheet implements
,
,
,
,
,
,
,
,
,
,
,
,
If true, the ActionSheet will open. Useful for controllable state behaviour
Callback invoked when the modal is closed
If true, disables the overlay.
If true, hides the drag indicator.
Props applied on Overlay.
ActionsheetContent implements
,
,
,
,
,
,
,
,
,
,
,
,
ActionsheetItem implements
NativeBase ships with a default theme for each component. Check out the default theme of the actionsheet
.
Info:
We can easily extend the actionsheet component theme using extendTheme function as described in the documentation .ActionSheet has aria-modal set to true.
ActionSheet has role set to dialog.
When the ActionSheet opens, focus is trapped within it.
Pressing Esc closes the ActionSheet.
When the ActionSheet opens, focus is automatically set to the first enabled element.
Clicking on the overlay closes the ActionSheet.
Scrolling is blocked on the elements behind the ActionSheet.