Skip to main content

Command Palette

Search for a command to run...

React - Styled Components(beginner)

Published
1 min readView as Markdown
S

Github: https://github.com/HODLBAEK

<Software Engineer> I'm a self-taught Frontend Developer passionate about web development. I use HTML, CSS, Sass, Javascript, React.

As an ex-banker, I also am very passionate about #BTC and what it could mean to humanity and money as we know it.

const Father = styled.div`
  display: flex;`

const Box = styled.div`
  background-color: ${(props) => props.bgColor};   //receiving props from JSX
  width: 100px;
  height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;`

const Circle = styled(Box)`   //getting styles from Box 
  border-radius: 50%;`

function App() {
  return (
    <Father>
      <Box bgColor="teal" />   //sending props to Components
      <Circle bgColor="tomato" />
    </Father>
  )
}

works like this.. image.png