Skip to content

Need help with dynamic theme using Unistyles v2 #125

Closed Answered by jpudysz
ryan-brs asked this question in Q&A
Discussion options

You must be logged in to vote

I believe there is a more efficient way to approach this, @ryan-brs. You can actually name your breakpoints whatever you prefer. For instance, you could define them as follows:

export const breakpoints = {
  mobile: 0,
  tablet: 772,
  desktop: 1024
}

After registering them, you can easily access the breakpoint flag in your component like this:

const { breakpoint } = useStyles(stylesheet)
// Here, 'breakpoint' could be 'mobile', 'tablet', or 'desktop'

Reference: Use Styles - Basic Usage Breakpoint

I guess you can also replace other dynamic parts and finalize your themes to be static.

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@ryan-brs
Comment options

@jpudysz
Comment options

@ryan-brs
Comment options

@jpudysz
Comment options

Answer selected by ryan-brs
@ryan-brs
Comment options

@jpudysz
Comment options

@ryan-brs
Comment options

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