fullscreenSupported (hooks/useFullscreen.ts)

imcodes · web/src/hooks/useFullscreen.ts · typescript · MIT
ui, tag:embed-classified

React hook for fullscreen element control with state and toggle functionality

// Source: https://github.com/im4codes/imcodes | License: MIT | Copyright 2026 IM.codes
// Provided via justclaw.it.com; keep this notice with the code.
import { useCallback, useEffect, useState } from 'preact/hooks';

export interface FullscreenControl {
  /** Is *this* element the one the browser is currently showing fullscreen? */
  active: boolean;
  /** Can this browser put this element fullscreen at all? */
  supported: boolean;
  /** Enter fullscreen on this element, or leave if it is already the one. Resolves false if the browser refused. */
  toggle(): Promise<boolean>;
}

/** Does the browser offer fullscreen here at all? */
export function fullscreenSupported(): boolean {
  if (typeof document === 'undefined') return false;
  // An iframe without `allowfullscreen` reports `false

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key