Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Working with Spacing | Section
Styling and Layout in React Native Apps

bookWorking with Spacing

Swipe um das Menü anzuzeigen

Spacing is the simplest way to improve how your UI looks.

Without spacing, elements feel crowded. With proper spacing, your screen becomes clear and easy to read.

There are two main types of spacing:

  • margin: space outside an element;
  • padding: space inside an element.

Example:

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

export default function App() {
  return (
    <View style={styles.container}>
      <Text style={styles.box}>First</Text>
      <Text style={styles.box}>Second</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    padding: 20
  },
  box: {
    backgroundColor: 'lightgray',
    padding: 10,
    marginBottom: 10
  }
});

Here:

  • padding adds space inside each box;
  • marginBottom creates space between elements.

Spacing helps your UI "breathe" and makes content easier to scan.

At this stage, focus on adding simple spacing between sections and inside components.

question mark

What does margin control?

Wählen Sie die richtige Antwort aus

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 2

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Abschnitt 1. Kapitel 2
some-alt