Draw a horizontal line in React-Code Examples

Radu TM

Draw a horizontal line in React

JavaScript by Radu TM June 16, 2022

import React, { useState } from 'react';

const Line = () => {
  // useState hook allows us to access state in a functional component
  const [color, setColor] = useState('black');

  return (
    <div>
      <h3>Draw a horizontal line in React</h3>
      <hr
        style={{
          color: color,
          backgroundColor: color,
          height: 5
        }}
      />
      <button onClick={() => setColor('green')}>Green</button>
      <button onClick={() => setColor('blue')}>Blue</button>
      <button onClick={() => setColor('red')}>Red</button>
    </div>
  );
};

export default Line;

0

25.373

Draw a horizontal line in React

JavaScript by Radu TM June 16, 2022

import React from "react";

//Draw a horizontal line in React
const HorizontalLine = () => {
  return (
    <hr
      style={{
        color: "lightgray",
        backgroundColor: "lightgray",
        height: 1,
        border: "none",
      }}
    />
  );
};

export default HorizontalLine;

0

25.373

Related JavaScript Queries

Latest JavaScript Queries

Explore code examples by categories