Easy to use UI components for React Native. Creating an app has never been easier!
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
yarn add react-native-basic-ui
or
npm install react-native-basic-ui
Also, complete installation of react-native-vector-icons and react-native-linear-gradient, otherwise you won't be able to use the Icon component and linear gradients.
You have to add a theme context to your app's root component. A default theme will be used.
import { ThemeProvider } from 'react-native-basic-ui';
const App = () => {
return (
<ThemeProvider>
...
</ThemeProvider>
);
}
But you can set your own primitives and overwrite the default theme. For example:
import { defaultTheme, ThemeProvider } from 'react-native-basic-ui';
const customTheme = {
...defaultTheme,
colors: {
..defaultTheme.colors,
primary: 'green',
},
};
const App = () => {
return (
<ThemeProvider value={customTheme}>
...
</ThemeProvider>
);
}
Once you have included ThemeProvider in your app, you can use the components:
import { Button, CenterContainer } from 'react-native-basic-ui';
const ExampleComponent = () => {
return (
<CenterContainer>
<Button text="Hello world" />
</CenterContainer>
);
};
To use the theme in your own components, you can use useStyles
hook. You can define styles while using theme primitives:
import { useStyles } from 'react-native-basic-ui';
const injectTheme = ({ colors, radiuses, spacing }) =>
StyleSheet.create({
container: {
backgroundColor: colors.primary,
borderRadius: radiuses.medium,
borderTopColor: colors.white,
marginBottom: spacing.small,
},
});
const ExampleComponent = () => {
const styles = useStyles(injectTheme);
return (
<View style={styles.container}>
...
</View>
);
};
And you can also access the theme object anywhere in the app:
import { useTheme } from 'react-native-basic-ui';
const ExampleComponent = (props) => {
const { isError } = props;
const { colors } = useTheme();
const color = isError ? colors.danger : colors.primary;
return (
<Text style={{ color }}>
Hello world
</Text>
);
};
Coming soon
Check this Expo.
Is it compatible with Expo?
Yes, it is, thanks to @expo/vector-icons and expo-linear-gradient.
Can I change the default props?
No. If you want to overwrite the default props you have to create your own component which extends this UI's component. For example if you want your Scalable
to always have a scale of 0.5, you would need to create a new component which extends UI's Scalable
and passes this prop to it.
Can I change the theme dynamically?
Yes, you can, however the whole app would be re-rendered.
Author: janziemba
Source Code: https://github.com/janziemba/react-native-basic-ui
Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.
Skenix is providing React Native Development Services with qualified React Native App Developers. Get the best React Native App Development Services.
Are you a mobile app developer looking for more efficient tools for your projects? Mobile app development is getting tougher and tougher as the market continues to grow. As a developer, you need to develop Apps which meet the demands of your users. To achieve this, adopt the right tools, like the React Native development framework.
Looking for top React Native mobile app development company in USA for Startups & Enterprise? Find out the top list of React Native mobile app development company in USA.
Hire top react native app development company in New York to build and develop custom react native mobile apps for Android & iOS with the latest features.