`How to add the same styles to two elements at once in styled-components?
A
A
Alexander2021-06-21 16:20:43
css
Alexander, 2021-06-21 16:20:43

How to add the same styles to two elements at once in styled-components?

export const PrevBtn = styled.div`
  svg {
    display: flex;
    color: ${(props) => props.theme.colors.primary};
    font-size: 50px;
    cursor: pointer;
  }
`
export const NextBtn = styled.div`
  svg {
    display: flex;
    color: ${(props) => props.theme.colors.primary};
    font-size: 50px;
    cursor: pointer;
  }
`

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Timoshenkov, 2021-06-22
@axrising

Your styles are declared as constants, so you can just use one of them or make it common:

const commonStyles = styled.div`
  svg {
    display: flex;
    color: ${(props) => props.theme.colors.primary};
    font-size: 50px;
    cursor: pointer;
  }
`
export const PrevBtn = commonStyles
export const NextBtn = commonStyles

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question