Implement dynamic media query settings using Tailwind CSS
P粉141911244
2023-08-26 20:54:45
<p>In my React JS application I have a component and I want to set a mobile breakpoint based on a variable: </p>
<pre class="brush:php;toolbar:false;"><Component size={'500px'}/>
const Component = ({size}) => {
return (
<div md:flex>hello</div>
)
}</pre>
<p>I want to add something like <code>[size]:flex</code> where <code>md:flex</code> will set a breakpoint based on that property. (eg: if the size is 500px or 100px or 900px, set it to display flex) </p><p> Question: Is it possible to set media queries the way I described above? </p>
You can use classnames npm package: