NA +91-8727899942 thecoderjob@gmail.com

CHAPTER - 11

Style in React Native || what are the different style type.

In React Native, there are two primary ways to apply styles to components:

  1. Inline Styles: Styles can be applied directly to components using the style prop with a JavaScript object.

  2. StyleSheet: React Native provides a StyleSheet API that allows you to define styles in a separate object, which can improve performance by optimizing the styles during compilation.

Here's is the Code !!

//Inline Styles
import React from 'react';
import { View, Text } from 'react-native';

const MyComponent = () => {
  return (
    <View style={{ backgroundColor: 'blue', padding: 20 }}>
      <Text style={{ color: 'white', fontSize: 18 }}>Hello, React Native!</Text>
    </View>
  );
};

export default MyComponent;

//StyleSheet
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';

const styles = StyleSheet.create({
  container: {
    backgroundColor: 'blue',
    padding: 20,
  },
  text: {
    color: 'white',
    fontSize: 18,
  },
});

const MyComponent = () => {
  return (
    <View style={styles.container}>
      <Text style={styles.text}>Hello, React Native!</Text>
    </View>
  );
};

export default MyComponent;

Chapter 10

what is props in react native?

Previous chapter

Chapter 12

How get text Input value || Handling text input value?

Next chapter

Get In Touch

NA

thecoderjob@gmail.com

+91-8727899942

Popular Links

© www.thecoderjob.com. All Rights Reserved.               Designed by HTML Codex