Skip to content
Sveltier
Mode
API

useDisplay

Returns reactive breakpoint flags for the current viewport.

Signature

Signature
import { useDisplay, type DisplayInstance } from 'sveltier';

function useDisplay(): DisplayInstance;

Call it during component initialisation. Every component gets the same instance, built on one MediaQuery per threshold; nothing listens to resize events.

Returns

NameTypeDescription
name'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'The current breakpoint.
xs … xxlbooleanWhether the viewport is within that breakpoint.
smAndUp … xlAndUpbooleanWhether the viewport is at that breakpoint or wider.
smAndDown … xlAndDownbooleanWhether the viewport is at that breakpoint or narrower.
mobilebooleanWhether the viewport is narrower than the mobile breakpoint (md by default).
thresholdsReadonly<DisplayThresholds>The minimum width in px of sm, md, lg, xl and xxl.

See Display for the breakpoints and how server rendering works.