Back to Mantine

Use Os

apps/mantine.dev/src/pages/hooks/use-os.mdx

9.2.0953 B
Original Source

import { UseOsDemos } from '@docs/demos'; import { Layout } from '@/layout'; import { MDX_DATA } from '@/mdx';

export default Layout(MDX_DATA.useOs);

Usage

The use-os hook returns the user's operating system. Possible values are: undetermined, macos, ios, windows, android, linux, chromeos. If the OS cannot be identified, for example, during server-side rendering, undetermined will be returned.

<Demo data={UseOsDemos.usage} />

Definition

tsx
type UseOSReturnValue =
  | 'undetermined'
  | 'macos'
  | 'ios'
  | 'windows'
  | 'android'
  | 'linux'
  | 'chromeos';

interface UseOsOptions {
  getValueInEffect: boolean;
}

function getOS(options?: UseOsOptions): UseOSReturnValue;

Exported types

UseOsOptions and UseOSReturnValue types are exported from the @mantine/hooks package; you can import them in your application:

tsx
import type { UseOsOptions, UseOSReturnValue } from '@mantine/hooks';