Are there media queries? #57725
scottfennell-toptal
started this conversation in
Developer Experience
Replies: 1 comment
-
|
I’d guess you may have figured this out by now. Anyway, if we’re talking about developing blocks or using react components in general the compose package has import { useMediaQuery } from '@wordpress/compose';
const MyComponent = () => {
const isNarrow = useMediaQuery( '(max-width: 382px)' );
if ( isNarrow ) {
// make it blue
}
// …
};Yet for the majority of cases it’s likely preferable to write media queries in CSS. There’s nothing different about using them with Gutenberg/React. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm an experienced (old school) wp dev, trying to give gutenberg a fair chance. I see there are a lot of UI's for controlling various aspects of block content and design. But what about media queries? To make it super simple, how do I make something red on wide screens, but blue on narrow screens?
Beta Was this translation helpful? Give feedback.
All reactions