How to create a style component in reactjs

In reactjs use ‘styled-components’ library to use style on specific component . You can install this package through npm i styled-components


Here is an example code how to use an style component in reactjs

import styled from 'styled-components';

const StyledButton = styled.button`
  background-color: palevioletred;
  color: white;
  font-size: 1em;
  margin: 1em;
  padding: 0.25em 1em;
  border: 2px solid palevioletred;
  border-radius: 3px;

function MyComponent() {
  return <StyledButton>Click me!</StyledButton>;



Leave a Reply

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