Categories
JavaScript Answers React Native Answers

How to draw a horizontal rule in React Native?

Spread the love

Sometimes, we want to draw a horizontal rule in React Native.

In this article, we’ll look at how to draw a horizontal rule in React Native.

How to draw a horizontal rule in React Native?

To draw a horizontal rule in React Native, we can add a View with a border color and width.

For instance, we write:

import * as React from 'react';
import { Text, View } from 'react-native';

import { Card } from 'react-native-paper';

const App = () => {
  return (
    <View style={{ flex: 1 }}>
      <Text>hello</Text>
      <View
        style={{
          borderBottomColor: 'black',
          borderBottomWidth: 1,
        }}
      />
      <Text>world</Text>
    </View>
  );
};
export default App;

to add the View between 2 Text components.

We set the borderBottomColor to 'black' to add a border color.

And then we set borderBottomWidth to 1 to add a border width in pixels.

Conclusion

To draw a horizontal rule in React Native, we can add a View with a border color and width.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *