getCurrentBreakpoint(): Breakpoint¶
The getCurrentBreakpoint
method allows you to get a currently active breakpoint.
Returned value¶
A returned value has a type of Breakpoint
which represents the Breakpoint model.
Example¶
In this example we make a ResolutionDetectorApi
call to get a currently active breakpoint.
useStorefront(async (storefront) => {
const resolutionDetectorApi = storefront.getApiSync('ResolutionDetectorApi');
const currentBreakpoint = resolutionDetectorApi.getCurrentBreakpoint();
console.log(`Current breakpoint is ${currentBreakpoint.name} which applies to screens of ${currentBreakpoint.value}px width and below.`);
});