useDisplay
Commons
stable
Reactive display breakpoint detection. Returns the current viewport breakpoints, platform info, and a component-scoped mobile class. Must be consumed inside an app that has called createDisplay() during plugin setup.
API
Signature
Signature TypeScript complète extraite du fichier du composable.
Interfaces consommées
IDisplayProps
IDisplayInstance
IDisplayOptions
API
Paramètres
Paramètres d'entrée acceptés par ce composable.
- propsIDisplayProps{}
- Optional props object containing mobileBreakpoint. When provided, overrides the global mobileBreakpoint threshold for this component instance.
- namestringgetCurrentInstanceName()
- Component name used to generate the scoped mobile CSS class (e.g. "my-component--mobile"). Defaults to the current Vue instance name.
API
Valeurs de retour
Propriétés et méthodes exposées par l'objet retourné par le composable.
- xs / sm / md / lg / xl / xxl
- Boolean refs indicating whether the current viewport matches each named breakpoint exactly.
- smAndUp / mdAndUp / lgAndUp / xlAndUp
- True when the viewport is at or above the named breakpoint.
- smAndDown / mdAndDown / lgAndDown / xlAndDown
- True when the viewport is at or below the named breakpoint.
- mobile
- True when the viewport width is below the resolved mobileBreakpoint threshold (global or instance-level).
- displayClasses
- Class map to bind on the component root. Adds `{name}--mobile` when mobile is true.
- width / height
- Current viewport width and height in pixels, updated on window resize.
- platform
- Platform detection object with boolean flags for android, ios, chrome, firefox, win, mac, touch, ssr, etc.
- thresholds
- Resolved pixel thresholds for each breakpoint (sm, md, lg, xl, xxl).
- name
- The active breakpoint name as a string: "xs", "sm", "md", "lg", "xl" or "xxl".
Usage
Exemples
Extraits de code prêts à coller.
Conditional rendering by breakpoint
Custom mobileBreakpoint per component