@@ -864,6 +864,7 @@ Supported values:
864864 <video playsInline autoPlay muted loop >
865865 <source src =" /assets/7.x/native-stack/presentation-fullScreenModal.mp4 " />
866866 </video >
867+
867868- ` formSheet ` : will use "BottomSheetBehavior" on Android and "UIModalPresentationFormSheet" modal style on iOS.
868869 <video playsInline autoPlay muted loop >
869870 <source src =" /assets/7.x/native-stack/presentation-formSheet-android.mp4 " />
@@ -872,6 +873,169 @@ Supported values:
872873 <source src =" /assets/7.x/native-stack/presentation-formSheet-ios.mp4 " />
873874 </video >
874875
876+ ##### Using Form Sheet
877+
878+ To use Form Sheet for your screen, add ` presentation: 'formSheet' ` to the ` options ` .
879+
880+ <Tabs groupId =" config " queryString =" config " >
881+ <TabItem value =" static " label =" Static " default >
882+
883+ ``` js name="Form Sheet" snack
884+ import * as React from ' react' ;
885+ import { Text , View } from ' react-native' ;
886+ import {
887+ createStaticNavigation ,
888+ useNavigation ,
889+ } from ' @react-navigation/native' ;
890+ import { Button } from ' @react-navigation/elements' ;
891+
892+ // codeblock-focus-start
893+ import { createNativeStackNavigator } from ' @react-navigation/native-stack' ;
894+
895+ // codeblock-focus-end
896+
897+ function HomeScreen () {
898+ const navigation = useNavigation ();
899+
900+ return (
901+ < View style= {{ flex: 1 , alignItems: ' center' , justifyContent: ' center' }}>
902+ < Text > Home Screen< / Text >
903+ < Button onPress= {() => navigation .navigate (' Profile' )}>
904+ Go to Profile
905+ < / Button>
906+ < / View>
907+ );
908+ }
909+
910+ function ProfileScreen () {
911+ const navigation = useNavigation ();
912+
913+ return (
914+ < View style= {{ padding: 15 }}>
915+ < Text style= {{ fontSize: 30 , fontWeight: ' bold' }}> Profile Screen< / Text >
916+ < Text style= {{ marginTop: 10 }}>
917+ Lorem ipsum dolor sit amet, consectetur adipiscing elit . Etiam accumsan
918+ euismod enim, quis porta ligula egestas sed . Maecenas vitae consequat
919+ odio, at dignissim lorem . Ut euismod eros ac mi ultricies, vel pharetra
920+ tortor commodo . Interdum et malesuada fames ac ante ipsum primis in
921+ faucibus . Nullam at urna in metus iaculis aliquam at sed quam . In
922+ ullamcorper, ex ut facilisis commodo, urna diam posuere urna, at
923+ condimentum mi orci ac ipsum . In hac habitasse platea dictumst . Donec
924+ congue pharetra ipsum in finibus . Nulla blandit finibus turpis, non
925+ vulputate elit viverra a . Curabitur in laoreet nisl.
926+ < / Text >
927+ < Button onPress= {() => navigation .goBack ()} style= {{ marginTop: 15 }}>
928+ Go back
929+ < / Button>
930+ < / View>
931+ );
932+ }
933+
934+ // codeblock-focus-start
935+ const MyStack = createNativeStackNavigator ({
936+ screens: {
937+ Home: {
938+ screen : HomeScreen,
939+ },
940+ Profile: {
941+ screen : ProfileScreen,
942+ options: {
943+ presentation: ' formSheet' ,
944+ headerShown: false ,
945+ sheetAllowedDetents: ' fitToContents' ,
946+ },
947+ },
948+ },
949+ });
950+ // codeblock-focus-end
951+
952+ const Navigation = createStaticNavigation (MyStack);
953+
954+ export default function App () {
955+ return < Navigation / > ;
956+ }
957+ ```
958+
959+ </TabItem >
960+ <TabItem value =" dynamic " label =" Dynamic " >
961+
962+ ``` js name="Form Sheet" snack
963+ import * as React from ' react' ;
964+ import { Text , View } from ' react-native' ;
965+ import { NavigationContainer , useNavigation } from ' @react-navigation/native' ;
966+ import { Button } from ' @react-navigation/elements' ;
967+ // codeblock-focus-start
968+ import { createNativeStackNavigator } from ' @react-navigation/native-stack' ;
969+
970+ const Stack = createNativeStackNavigator ();
971+
972+ function MyStack () {
973+ return (
974+ < Stack .Navigator >
975+ < Stack .Screen name= " Home" component= {HomeScreen} / >
976+ < Stack .Screen
977+ name= " Profile"
978+ component= {ProfileScreen}
979+ options= {{
980+ presentation: ' formSheet' ,
981+ headerShown: false ,
982+ sheetAllowedDetents: ' fitToContents' ,
983+ }}
984+ / >
985+ < / Stack .Navigator >
986+ );
987+ }
988+ // codeblock-focus-end
989+
990+ function HomeScreen () {
991+ const navigation = useNavigation ();
992+
993+ return (
994+ < View style= {{ flex: 1 , alignItems: ' center' , justifyContent: ' center' }}>
995+ < Text > Home Screen< / Text >
996+ < Button onPress= {() => navigation .navigate (' Profile' )}>
997+ Go to Profile
998+ < / Button>
999+ < / View>
1000+ );
1001+ }
1002+
1003+ function ProfileScreen () {
1004+ const navigation = useNavigation ();
1005+
1006+ return (
1007+ < View style= {{ padding: 15 }}>
1008+ < Text style= {{ fontSize: 30 , fontWeight: ' bold' }}> Profile Screen< / Text >
1009+ < Text style= {{ marginTop: 10 }}>
1010+ Lorem ipsum dolor sit amet, consectetur adipiscing elit . Etiam accumsan
1011+ euismod enim, quis porta ligula egestas sed . Maecenas vitae consequat
1012+ odio, at dignissim lorem . Ut euismod eros ac mi ultricies, vel pharetra
1013+ tortor commodo . Interdum et malesuada fames ac ante ipsum primis in
1014+ faucibus . Nullam at urna in metus iaculis aliquam at sed quam . In
1015+ ullamcorper, ex ut facilisis commodo, urna diam posuere urna, at
1016+ condimentum mi orci ac ipsum . In hac habitasse platea dictumst . Donec
1017+ congue pharetra ipsum in finibus . Nulla blandit finibus turpis, non
1018+ vulputate elit viverra a . Curabitur in laoreet nisl.
1019+ < / Text >
1020+ < Button onPress= {() => navigation .goBack ()} style= {{ marginTop: 15 }}>
1021+ Go back
1022+ < / Button>
1023+ < / View>
1024+ );
1025+ }
1026+
1027+ export default function App () {
1028+ return (
1029+ < NavigationContainer>
1030+ < MyStack / >
1031+ < / NavigationContainer>
1032+ );
1033+ }
1034+ ```
1035+
1036+ </TabItem >
1037+ </Tabs >
1038+
8751039::: warning
8761040
8771041Due to technical issues in platform component integration with ` react-native ` , ` presentation: 'formSheet' ` on Android has limited support for ` flex: 1 ` . The tradeoff is necessary to prevent "sheet flickering" problem. There are also some problems with getting nested ScrollViews to work properly.
0 commit comments