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

Release Preview

This release is in preview. Features described here don't become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can't guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.