npx @react-native-community/cli init MyNotes
Here's a breakdown of separate React Native .tsx screen files for your Android app. Each screen corresponds to a basic HTML/CSS concept and can be used for an educational or tutorial-based app. These screens are built using TypeScript and follow common React Native conventions.
✅ File Structure Suggestion:
/screens
├── HtmlHeadingBasicsScreen.tsx
├── HtmlParagraphsScreen.tsx
├── HtmlImageDisplayScreen.tsx
├── HtmlPageLinksScreen.tsx
├── CssTypesScreen.tsx
├── ExternalCssUsageScreen.tsx
├── CssFlexboxBasicsScreen.tsx
🧩 1. HtmlHeadingBasicsScreen.tsx
import React from 'react';
import { View, Text, ScrollView, StyleSheet } from 'react-native';
const HtmlHeadingBasicsScreen = () => {
return (
HTML Heading Basics
{[1, 2, 3, 4, 5, 6].map((level) => (
H{level} Heading Example
))}
);
};
const styles = StyleSheet.create({
container: {
padding: 20,
},
heading: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 20,
},
h1: { fontSize: 32, fontWeight: 'bold', marginBottom: 10 },
h2: { fontSize: 28, fontWeight: 'bold', marginBottom: 10 },
h3: { fontSize: 24, fontWeight: '600', marginBottom: 10 },
h4: { fontSize: 20, fontWeight: '600', marginBottom: 10 },
h5: { fontSize: 16, fontWeight: '500', marginBottom: 10 },
h6: { fontSize: 14, fontWeight: '500', marginBottom: 10 },
});
export default HtmlHeadingBasicsScreen;
🧩 2. HtmlParagraphsScreen.tsx
import React from 'react';
import { View, Text, StyleSheet, ScrollView } from 'react-native';
const HtmlParagraphsScreen = () => {
return (
HTML Paragraphs
A paragraph is defined with the <p> tag. Paragraphs are usually blocks of text separated by vertical space.
HTML automatically adds space before and after paragraphs.
);
};
const styles = StyleSheet.create({
container: {
padding: 20,
},
heading: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 20,
},
paragraph: {
fontSize: 16,
marginBottom: 15,
lineHeight: 22,
},
});
export default HtmlParagraphsScreen;
🧩 3. HtmlImageDisplayScreen.tsx
import React from 'react';
import { View, Text, Image, StyleSheet } from 'react-native';
const HtmlImageDisplayScreen = () => {
return (
HTML Image Display
Images in HTML are displayed using the <img> tag.
Example of an image in HTML
);
};
const styles = StyleSheet.create({
container: {
padding: 20,
alignItems: 'center',
},
heading: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 20,
},
paragraph: {
fontSize: 16,
marginBottom: 15,
textAlign: 'center',
},
image: {
width: 200,
height: 200,
marginVertical: 20,
},
caption: {
fontSize: 14,
fontStyle: 'italic',
},
});
export default HtmlImageDisplayScreen;
🧩 4. HtmlPageLinksScreen.tsx
import React from 'react';
import { View, Text, Linking, StyleSheet, TouchableOpacity } from 'react-native';
const HtmlPageLinksScreen = () => {
const openLink = () => {
Linking.openURL('https://www.w3schools.com/html/');
};
return (
HTML Page Links
Use the <a> tag to define a hyperlink.
Go to W3Schools HTML Tutorial
);
};
const styles = StyleSheet.create({
container: {
padding: 20,
alignItems: 'center',
},
heading: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 20,
},
paragraph: {
fontSize: 16,
marginBottom: 15,
textAlign: 'center',
},
link: {
fontSize: 16,
color: 'blue',
textDecorationLine: 'underline',
},
});
export default HtmlPageLinksScreen;
🧩 5. CssTypesScreen.tsx
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
const CssTypesScreen = () => {
return (
Types of CSS
1. Inline CSS
2. Internal CSS
3. External CSS
);
};
const styles = StyleSheet.create({
container: {
padding: 20,
},
heading: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 20,
},
item: {
fontSize: 18,
marginBottom: 10,
},
});
export default CssTypesScreen;
🧩 6. ExternalCssUsageScreen.tsx
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
const ExternalCssUsageScreen = () => {
return (
Using External CSS
External CSS is used by linking a CSS file using the <link> tag inside the HTML <head> section.
{''}
);
};
const styles = StyleSheet.create({
container: {
padding: 20,
},
heading: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 20,
},
paragraph: {
fontSize: 16,
marginBottom: 15,
},
code: {
fontFamily: 'monospace',
backgroundColor: '#eee',
padding: 10,
borderRadius: 5,
},
});
export default ExternalCssUsageScreen;
🧩 7. CssFlexboxBasicsScreen.tsx
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
const CssFlexboxBasicsScreen = () => {
return (
CSS Flexbox Basics
Flexbox is a layout model that provides an efficient way to layout, align, and distribute space among items in a container.
1
2
3
);
};
const styles = StyleSheet.create({
container: {
padding: 20,
},
heading: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 20,
},
paragraph: {
fontSize: 16,
marginBottom: 15,
},
flexContainer: {
flexDirection: 'row',
justifyContent: 'space-around',
marginTop: 20,
},
box: {
backgroundColor: '#ccc',
padding: 20,
borderRadius: 8,
alignItems: 'center',
},
});
export default CssFlexboxBasicsScreen;
🚀 Next Steps
To use these screens in your app:
Import them in your navigator (e.g., React Navigation).
Add them to your stack or tab navigator.
Organize routing based on categories (HTML/CSS sections).
--------------------------------------------
To import and use these screens in your navigator using React Navigation (e.g., a Stack Navigator), follow these steps:
✅ Prerequisites
Make sure you have React Navigation installed:
npm install @react-navigation/native @react-navigation/native-stack
npx expo install react-native-screens react-native-safe-area-context
Or for bare React Native projects:
npm install react-native-screens react-native-safe-area-context react-native-gesture-handler react-native-reanimated react-native-vector-icons
Then install the stack navigator:
npm install @react-navigation/native-stack
📁 File: App.tsx
Here’s how to import all the screens and set up navigation:
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
// Import all your screens
import HtmlHeadingBasicsScreen from './screens/HtmlHeadingBasicsScreen';
import HtmlParagraphsScreen from './screens/HtmlParagraphsScreen';
import HtmlImageDisplayScreen from './screens/HtmlImageDisplayScreen';
import HtmlPageLinksScreen from './screens/HtmlPageLinksScreen';
import CssTypesScreen from './screens/CssTypesScreen';
import ExternalCssUsageScreen from './screens/ExternalCssUsageScreen';
import CssFlexboxBasicsScreen from './screens/CssFlexboxBasicsScreen';
const Stack = createNativeStackNavigator();
const App = () => {
return (
);
};
export default App;
🧠 Tips
You can create a HomeScreen.tsx with buttons to navigate to each tutorial screen.
For easier navigation, consider grouping screens by topics using a Tab or Drawer Navigator.
Would you like me to generate a HomeScreen with buttons for navigating to each topic?
You said:
this both is necessary npm install @react-navigation/native @react-navigation/native-stack
npx expo install react-native-screens react-native-safe-area-context
ChatGPT said:
Great question — whether both commands are necessary depends on how your project is set up:
🟢 If you are using Expo:
✅ Use only this command:
npx expo install react-native-screens react-native-safe-area-context
It ensures compatible versions of dependencies are installed based on your Expo SDK version.
Then run:
npm install @react-navigation/native @react-navigation/native-stack
🔁 So yes, both commands are needed, but:
The first installs core navigation libraries (@react-navigation/native, @react-navigation/native-stack)
The second (with expo install) ensures proper versions of native dependencies required by React Navigation for Expo.
🔴 If you are using bare React Native (not Expo):
You do not use npx expo install.
Instead, run:
npm install @react-navigation/native @react-navigation/native-stack
npm install react-native-screens react-native-safe-area-context
Also install other native dependencies:
npm install react-native-gesture-handler react-native-reanimated
HomeScreen with buttons for navigating to each topic
ChatGPT said:
Great! Here's a simple HomeScreen.tsx file with buttons to navigate to each of your HTML/CSS tutorial screens using a React Native Stack Navigator.
🏠 HomeScreen.tsx
import React from 'react';
import { View, Text, StyleSheet, TouchableOpacity, ScrollView } from 'react-native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { useNavigation } from '@react-navigation/native';
// Define the type for navigation (optional but good for TypeScript)
type RootStackParamList = {
HtmlHeadingBasics: undefined;
HtmlParagraphs: undefined;
HtmlImageDisplay: undefined;
HtmlPageLinks: undefined;
CssTypes: undefined;
ExternalCssUsage: undefined;
CssFlexboxBasics: undefined;
};
type HomeScreenNavigationProp = NativeStackNavigationProp;
const HomeScreen = () => {
const navigation = useNavigation();
const topics = [
{ title: 'HTML Heading Basics', screen: 'HtmlHeadingBasics' },
{ title: 'HTML Paragraphs', screen: 'HtmlParagraphs' },
{ title: 'HTML Image Display', screen: 'HtmlImageDisplay' },
{ title: 'HTML Page Links', screen: 'HtmlPageLinks' },
{ title: 'CSS Types', screen: 'CssTypes' },
{ title: 'Using External CSS', screen: 'ExternalCssUsage' },
{ title: 'CSS Flexbox Basics', screen: 'CssFlexboxBasics' },
];
return (
Web Development Tutorials
{topics.map((topic, index) => (
navigation.navigate(topic.screen as keyof RootStackParamList)}
>
{topic.title}
))}
);
};
const styles = StyleSheet.create({
container: {
padding: 20,
alignItems: 'stretch',
},
heading: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 30,
textAlign: 'center',
},
button: {
backgroundColor: '#3498db',
padding: 15,
borderRadius: 8,
marginBottom: 15,
},
buttonText: {
color: '#fff',
fontSize: 16,
textAlign: 'center',
},
});
export default HomeScreen;
📁 Update App.tsx to include HomeScreen
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
// Screens
import HomeScreen from './screens/HomeScreen';
import HtmlHeadingBasicsScreen from './screens/HtmlHeadingBasicsScreen';
import HtmlParagraphsScreen from './screens/HtmlParagraphsScreen';
import HtmlImageDisplayScreen from './screens/HtmlImageDisplayScreen';
import HtmlPageLinksScreen from './screens/HtmlPageLinksScreen';
import CssTypesScreen from './screens/CssTypesScreen';
import ExternalCssUsageScreen from './screens/ExternalCssUsageScreen';
import CssFlexboxBasicsScreen from './screens/CssFlexboxBasicsScreen';
export type RootStackParamList = {
Home: undefined;
HtmlHeadingBasics: undefined;
HtmlParagraphs: undefined;
HtmlImageDisplay: undefined;
HtmlPageLinks: undefined;
CssTypes: undefined;
ExternalCssUsage: undefined;
CssFlexboxBasics: undefined;
};
const Stack = createNativeStackNavigator();
const App = () => {
return (
);
};
export default App;
🧠 Tip for Styling
You can customize button colors, layout, or group topics under sections like “HTML” and “CSS” if you want a cleaner UI.