function App() {const [showActionsheet, setShowActionsheet] = React.useState(false)const handleClose = () => setShowActionsheet(!showActionsheet)return (<Box><Button onPress={handleClose}><ButtonText>Open</ButtonText></Button><Actionsheet isOpen={showActionsheet} onClose={handleClose} zIndex={999}><ActionsheetBackdrop /><ActionsheetContent h="$72" zIndex={999}><ActionsheetDragIndicatorWrapper><ActionsheetDragIndicator /></ActionsheetDragIndicatorWrapper><ActionsheetItem onPress={handleClose}><ActionsheetItemText>Delete</ActionsheetItemText></ActionsheetItem><ActionsheetItem onPress={handleClose}><ActionsheetItemText>Share</ActionsheetItemText></ActionsheetItem><ActionsheetItem onPress={handleClose}><ActionsheetItemText>Play</ActionsheetItemText></ActionsheetItem><ActionsheetItem onPress={handleClose}><ActionsheetItemText>Favourite</ActionsheetItemText></ActionsheetItem><ActionsheetItem onPress={handleClose}><ActionsheetItemText>Cancel</ActionsheetItemText></ActionsheetItem></ActionsheetContent></Actionsheet></Box>)}
import { Actionsheet } from '@gluestack-ui/themed';
export default () => (<Actionsheet><ActionsheetBackdrop /><ActionsheetContent><ActionsheetDragIndicatorWrapper><ActionsheetDragIndicator /></ActionsheetDragIndicatorWrapper><ActionsheetItem><ActionsheetItemText /></ActionsheetItem></ActionsheetContent></Actionsheet>)
Prop | Type | Default | Description |
---|---|---|---|
isOpen | boolean | - | If true, the Actionsheet will open. Useful for controllable state behavior. |
onClose | () => any | - | Callback invoked when the Actionsheet is closed. |
onOpen | () => any | - | Callback invoked when the Actionsheet is opened. |
useRNModal | boolean | false | If true, renders react-native native modal. |
defaultIsOpen | boolean | - | Specifies the default open state of the Actionsheet |
initialFocusRef | React.RefObject<any> | - | The ref of element to receive focus when the Actionsheet opens. |
finalFocusRef | React.RefObject<any> | - | The ref of element to receive focus when the Actionsheet closes |
closeOnOverlayClick | boolean | - | If true, the Actionsheet will close when the overlay is clicked. |
isKeyboardDismissable | boolean | - | If true, the keyboard can dismiss the Actionsheet |
trapFocus | boolean | true | If true, creates a focus scope containing all elements within the Actionsheet content. |
children | any | - | The content to display inside the Actionsheet |
snapPoints | Array<number> | [50] | The snap points for the Actionsheet The Actionsheet will snap to the point closest to its current position. The default value is 50% of the screen height. The value should be between 0 and 100. Currently, only one snap point is supported. We plan to support multiple snap points in the future. |
Sx Prop | Description |
---|---|
_sectionHeaderText | Prop to style ActionsheetSectionHeaderText Component |
Sx Prop | Description |
---|---|
_text | Prop to style ActionsheetItemText Component |
_icon | Prop to style ActionsheetIcon Component |
function App() {const [showActionsheet, setShowActionsheet] = React.useState(false)const handleClose = () => setShowActionsheet(!showActionsheet)return (<><Button onPress={handleClose}><ButtonText>Open</ButtonText></Button><KeyboardAvoidingViewbehavior={Platform.OS === "ios" ? "padding" : undefined}><Actionsheet isOpen={showActionsheet} onClose={handleClose}><ActionsheetBackdrop /><ActionsheetContent maxHeight="75%"><ActionsheetDragIndicatorWrapper><ActionsheetDragIndicator /></ActionsheetDragIndicatorWrapper><VStack w="$full" p={20}><HStack justifyContent="center" alignItems="center" space="md"><Boxw={50}h="$full"px="$2"borderWidth={1}borderStyle="solid"borderColor="$borderLight300"rounded="$sm"><Imagesource={{ uri: "https://i.imgur.com/UwTLr26.png" }}flex={1}resizeMode="contain"/></Box><VStack flex={1}><Text fontWeight="$bold">Mastercard</Text><Text>Card ending in 2345</Text></VStack></HStack><FormControl mt={36}><FormControlLabel><FormControlLabelText>Confirm security code</FormControlLabelText></FormControlLabel><Input w="$full"><InputSlot><InputIcon as={LeadingIcon} ml="$2" /></InputSlot><InputField placeholder="CVC/CVV" /></Input><Button onPress={handleClose} mt={20}><ButtonText>Pay $1000</ButtonText></Button></FormControl></VStack></ActionsheetContent></Actionsheet></KeyboardAvoidingView></>)}
function App() {const [showActionsheet, setShowActionsheet] = React.useState(false)const handleClose = () => setShowActionsheet(!showActionsheet)return (<><Button onPress={handleClose}><ButtonText>Open</ButtonText></Button><ActionsheetisOpen={showActionsheet}onClose={handleClose}snapPoints={[50]}><KeyboardAvoidingViewbehavior="position"// eslint-disable-next-line react-native/no-inline-stylesstyle={{position: "relative",flex: 1,justifyContent: "flex-end",}}><ActionsheetBackdrop /><ActionsheetContent maxHeight="75%"><ActionsheetDragIndicatorWrapper><ActionsheetDragIndicator /></ActionsheetDragIndicatorWrapper><VStack w="$full" p={20}><HStack justifyContent="center" alignItems="center" space="md"><Boxw={50}h="$full"px="$2"borderWidth={1}borderStyle="solid"borderColor="$borderLight300"rounded="$sm"><Imagesource={{ uri: "https://i.imgur.com/UwTLr26.png" }}flex={1}resizeMode="contain"/></Box><VStack flex={1}><Text fontWeight="$bold">Mastercard</Text><Text>Card ending in 2345</Text></VStack></HStack><FormControl mt={36}><FormControlLabel><FormControlLabelText>Confirm security code</FormControlLabelText></FormControlLabel><Input w="$full"><InputSlot><InputIcon as={LeadingIcon} ml="$2" /></InputSlot><InputField placeholder="CVC/CVV" /></Input><Button onPress={handleClose} mt={20}><ButtonText>Pay $1000</ButtonText></Button></FormControl></VStack></ActionsheetContent></KeyboardAvoidingView></Actionsheet></>)}
function App() {const [showActionsheet, setShowActionsheet] = React.useState(false)const handleClose = () => setShowActionsheet(!showActionsheet)return (<><Button onPress={handleClose}><ButtonText>Open</ButtonText></Button><Actionsheet isOpen={showActionsheet} onClose={handleClose}><ActionsheetBackdrop /><ActionsheetContent><ActionsheetDragIndicatorWrapper><ActionsheetDragIndicator /></ActionsheetDragIndicatorWrapper><ActionsheetItem onPress={handleClose}><ActionsheetIcon><Icon as={TrashIcon} /></ActionsheetIcon><ActionsheetItemText>Delete</ActionsheetItemText></ActionsheetItem><ActionsheetItem onPress={handleClose}><ActionsheetIcon><Icon as={ShareIcon} /></ActionsheetIcon><ActionsheetItemText>Share</ActionsheetItemText></ActionsheetItem><ActionsheetItem onPress={handleClose}><ActionsheetIcon><Icon as={PlayIcon} /></ActionsheetIcon><ActionsheetItemText>Play</ActionsheetItemText></ActionsheetItem><ActionsheetItem onPress={handleClose}><ActionsheetIcon><Icon as={FavouriteIcon} /></ActionsheetIcon><ActionsheetItemText>Favourite</ActionsheetItemText></ActionsheetItem><ActionsheetItem onPress={handleClose}><ActionsheetIcon><Icon as={CloseIcon} /></ActionsheetIcon><ActionsheetItemText>Cancel</ActionsheetItemText></ActionsheetItem></ActionsheetContent></Actionsheet></>)}
function App() {const [showActionsheet, setShowActionsheet] = React.useState(false)const handleClose = () => setShowActionsheet(!showActionsheet)const data = React.useMemo(() =>Array(50).fill(0).map((_, index) => "Item" + index),[])const getItem = (_data, index) => ({id: Math.random().toString(12).substring(0),title: _data[index],})const getItemCount = (_data) => _data.lengthconst Item = React.useCallback(({ title }) => (<ActionsheetItem onPress={handleClose}><ActionsheetItemText>{title}</ActionsheetItemText></ActionsheetItem>),[handleClose])return (<><Button onPress={handleClose}><ButtonText>Open</ButtonText></Button><Actionsheet isOpen={showActionsheet} onClose={handleClose}><ActionsheetBackdrop /><ActionsheetContent><ActionsheetDragIndicatorWrapper><ActionsheetDragIndicator /></ActionsheetDragIndicatorWrapper><ActionsheetVirtualizedListh="$56"data={data}initialNumToRender={5}renderItem={({ item }) => <Item title={item.title} />}keyExtractor={(item) => item.id}getItemCount={getItemCount}getItem={getItem}/></ActionsheetContent></Actionsheet></>)}
function App() {const [showActionsheet, setShowActionsheet] = React.useState(false)const handleClose = () => setShowActionsheet(!showActionsheet)const DATA = [{id: "bd7acbea-c1b1-46c2-aed5-3ad53abb28ba",title: "First Item",},{id: "3ac68afc-c605-48d3-a4f8-fbd91aa97f63",title: "Second Item",},{id: "58694a0f-3da1-471f-bd96-145571e29d72",title: "Third Item",},]const Item = React.useCallback(({ title }) => (<ActionsheetItem onPress={handleClose}><ActionsheetItemText>{title}</ActionsheetItemText></ActionsheetItem>),[handleClose])return (<><Button onPress={handleClose}><ButtonText>Open</ButtonText></Button><Actionsheet isOpen={showActionsheet} onClose={handleClose}><ActionsheetBackdrop /><ActionsheetContent><ActionsheetDragIndicatorWrapper><ActionsheetDragIndicator /></ActionsheetDragIndicatorWrapper><ActionsheetFlatListdata={DATA}renderItem={({ item }) => <Item title={item.title} />}keyExtractor={(item) => item.id}/></ActionsheetContent></Actionsheet></>)}
function App() {const [showActionsheet, setShowActionsheet] = React.useState(false)const handleClose = () => setShowActionsheet(!showActionsheet)const DATA = [{title: "Main dishes",data: ["Pizza", "Burger", "Risotto"],},{title: "Sides",data: ["French Fries", "Onion Rings", "Fried Shrimps"],},{title: "Drinks",data: ["Water", "Coke", "Beer"],},{title: "Desserts",data: ["Cheese Cake", "Ice Cream"],},]return (<><Button onPress={handleClose}><ButtonText>Open</ButtonText></Button><Actionsheet isOpen={showActionsheet} onClose={handleClose}><ActionsheetBackdrop /><ActionsheetContent><ActionsheetDragIndicatorWrapper><ActionsheetDragIndicator /></ActionsheetDragIndicatorWrapper><ActionsheetSectionListh="$56"sections={DATA}keyExtractor={(item, index) => item + index}renderItem={({ item }) => (<ActionsheetItem onPress={handleClose}><ActionsheetItemText>{item}</ActionsheetItemText></ActionsheetItem>)}renderSectionHeader={({ section: { title, data } }) => (<ActionsheetSectionHeaderText>{title} ({data.length})</ActionsheetSectionHeaderText>)}/></ActionsheetContent></Actionsheet></>)}