Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Counter app with light/dark theme toggle using NativeBase components.
import React, { useState } from 'react';
import { NativeBaseProvider, Box, Button, VStack, Text, extendTheme } from 'native-base';
export default function App() {
const [count, setCount] = useState(0);
const [isDark, setIsDark] = useState(false);
const theme = extendTheme({ config: { initialColorMode: isDark ? 'dark' : 'light' } });
return (
<NativeBaseProvider theme={theme}>
<Box safeArea p={4} flex={1} alignItems="center" justifyContent="center">
<VStack space={4} alignItems="center">
<Text fontSize="2xl">Counter: {count}</Text>
<Button onPress={() => setCount(count + 1)}>+</Button>
<Button onPress={() => setCount(count - 1)}>-</Button>
<Button onPress={() => setCount(0)}>Reset</Button>
<Button onPress={() => setIsDark(!isDark)}>Toggle Theme</Button>
</VStack>
</Box>
</NativeBaseProvider>
);
}NativeBase is an open-source UI component library for React Native, providing a set of cross-platform, customizable components that accelerate mobile app development with consistent design.
Origin & Creator
Developed by GeekyAnts, first released in 2016 to simplify React Native UI development and provide a consistent cross-platform component library.
Industrial Note
NativeBase is widely used for startups, enterprise mobile apps, and cross-platform React Native projects that need rapid prototyping and production-ready UI components.