isXs(): boolean¶
The isXs
method allows you to get a boolean indicating whether a current breakpoint is an xs
or not. In other words it allows to check if we are currently on a mobile resolution. Read more about breakpoints in the Breakpoint model page.
Returned value¶
A returned value has a type of boolean
.
Example¶
In this example we make a ResolutionDetectorApi
call to see whether we are currently on a mobile resolution or not.
useStorefront(async (storefront) => {
const resolutionDetectorApi = storefront.getApiSync('ResolutionDetectorApi');
const isXs = resolutionDetectorApi.isXs();
if (isXs) {
console.log('We are currently on a mobile resolution');
}
});