Skip to content

Handling mobile specific styling #503

Closed Answered by eric-mathison
eric-mathison asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, I'm pretty sure I figured out how to accomplish this. I ended up using styled-components since you can pass props to the component and it will modify the css on the fly. I was struggling there for a bit because I'm using TailwindCSS for the bulk of the project and you can't use dynamic classes, even with JIT enabled. Plus inline styling just wouldn't work.

So for anyone interested, this is what the container component resulted as. This allows me to pass additional mobile settings to it.

const ContainerDiv = styled.div`
  display: flex;
  width: 100%;
  flex-direction: column;
  margin: ${({ margin }: ContainerProps) =>
    margin
      ? `${margin[0]}px ${margin[1]}px ${margin[2]}px $…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@hananint
Comment options

Answer selected by eric-mathison
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants