Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use CSS in ReactNative

Can I use CSS for styling my ReactNative component. Currently I can only use StyleSheet like this:

var styles = React.StyleSheet.create({
 autocomplete: {
   backgroundColor: '#FFF',
   zIndex: 5,
 },
 ...

I want to use CSS instead of this as in ReactJs

like image 880
PranavPinarayi Avatar asked Feb 27 '26 19:02

PranavPinarayi


1 Answers

First create a file named App.module.css

then write your pure css here

.container {
  background-color: rgb(44, 0, 95);
  width: 100%;
  height: 100%;
}

then,

import the file in your js file

import style from './App.module.css';

Now you can this style like normal react native styling

<View style={style.container}>
like image 126
AJO ALEX Avatar answered Mar 02 '26 09:03

AJO ALEX