For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.
Interface MediaQueryList
matches: boolean;
media: string;
onchange: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null;
addEventListener<K extends "change">(
type: K,
listener: (this: MediaQueryList, ev: MediaQueryListEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
addListener(
callback:
| ((this: MediaQueryList, ev: MediaQueryListEvent) => any)
| null,
): void;
dispatchEvent(event: Event): boolean;
removeEventListener<K extends "change">(
type: K,
listener: (this: MediaQueryList, ev: MediaQueryListEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void;
removeListener(
callback:
| ((this: MediaQueryList, ev: MediaQueryListEvent) => any)
| null,
): void;
}
Hierarchy
- EventTarget
- MediaQueryList
Properties
Readonlymatches
The matches read-only property of the MediaQueryList interface is a boolean value that returns true if the document currently matches the media query list, or false if not.
Readonlymedia
The media read-only property of the MediaQueryList interface is a string representing a serialized media query.
onchange
Methods
addEventListener
-
addEventListener<K extends "change">(
type: K,
listener: (this: MediaQueryList, ev: MediaQueryListEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): voidThe
addEventListener()method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.Type Parameters
- K extends "change"
Parameters
- type: K
- listener: (this: MediaQueryList, ev: MediaQueryListEventMap[K]) => any
Optionaloptions: boolean | AddEventListenerOptions
Returns void
-
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): voidThe
addEventListener()method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optionaloptions: boolean | AddEventListenerOptions
Returns void
addListener
-
The deprecated
addListener()method of the MediaQueryList interface adds a listener to the MediaQueryListener that will run a custom callback function in response to the media query status changing.Parameters
- callback: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null
Returns void
dispatchEvent
-
The
dispatchEvent()method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().Parameters
- event: Event
Returns boolean
removeEventListener
-
removeEventListener<K extends "change">(
type: K,
listener: (this: MediaQueryList, ev: MediaQueryListEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): voidThe
removeEventListener()method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.Type Parameters
- K extends "change"
Parameters
- type: K
- listener: (this: MediaQueryList, ev: MediaQueryListEventMap[K]) => any
Optionaloptions: boolean | EventListenerOptions
Returns void
-
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): voidThe
removeEventListener()method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optionaloptions: boolean | EventListenerOptions
Returns void
removeListener
-
The
removeListener()method of the MediaQueryList interface removes a listener from the MediaQueryListener.Parameters
- callback: ((this: MediaQueryList, ev: MediaQueryListEvent) => any) | null
Returns void
A
MediaQueryListobject stores information on a media query applied to a document, with support for both immediate and event-driven matching against the state of the document.MDN Reference