Access Client Form Factor

To access the form factor of the hardware the browser is running on, import the @salesforce/client/formFactor scoped module.

1import formFactorPropertyName from "@salesforce/client/formFactor";
  • formFactorPropertyName—A name that refers to the form factor of the hardware running the browser. Possible values are:
    • Large—A desktop client.
    • Medium—A tablet client.
    • Small—A phone client.

Pass the form factor to the getRecordCreateDefaults wire adapter to get the default layout and object information for creating a record.

1import { getRecordCreateDefaults } from 'lightning/uiRecordApi';
2import ACCOUNT_OBJECT from '@salesforce/schema/Account';
3import FORM_FACTOR from '@salesforce/client/formFactor';
4
5@wire(getRecordCreateDefaults, { objectApiName: ACCOUNT_OBJECT, formFactor: FORM_FACTOR})
6accountDefaults;

You can use @salesforce/client/formFactor in a TypeScript file. This scoped module corresponds to the client.d.ts type definition in the @salesforce/lightning-types npm package.

Note

See Also