Languages
[Edit]
EN

React - insert spaces to <pre> element

0 points
Created by:
Mariam-Barron
841

In this article, we would like to show you how to put spaces to <pre> element in React.

Quick solution:

<pre>
    Items: {'   '} 1st item {'    '} 2nd item
</pre>

 

Practical example

In this example, we use curly braces ({}) to insert spaces ('    ') into the <pre> element.

// ONLINE-RUNNER:browser;

//Note: Uncomment import lines during working with JSX Compiler.
// import React from "react";
// import ReactDOM from "react-dom";

const App = () => {
    return (
        <pre>
            Items: {'   '} 1st item {'    '} 2nd item
        </pre>
    );
};

const root = document.querySelector('#root');
ReactDOM.render(<App />, root);

Alternative titles

  1. React - insert space characters to <pre> element
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join