@shopify/polaris-types
v2.0.0
Published
Type definitions for [Polaris web components](https://shopify.dev/docs/api/app-home/polaris-web-components).
Keywords
Readme
@shopify/polaris-types
Type definitions for Polaris web components.
Installation
Add the types package as a dev dependency:
npm i -D @shopify/polaris-typesUsage
Since Polaris web components are not imported directly, you need to add the types to your TypeScript configuration in one of the following ways:
Method 1: Add to tsconfig.json
{
"compilerOptions": {
"types": ["@shopify/polaris-types"]
}
}Method 2: Add as a triple-slash reference
Add the following line at the top of your TypeScript files where you need the types:
/// <reference types="@shopify/polaris-types" />Custom Elements Manifest
This package includes a Custom Elements Manifest (custom-elements.json) that describes the Polaris web components in a standardized format. The manifest is generated using @custom-elements-manifest/analyzer with custom Polaris plugins.
IDE extensions and other tooling that understand the CEM format can use this to provide autocomplete, documentation, and other rich features for Polaris web components.
Accessing the manifest
// Via package.json "customElements" field (recommended for tooling)
// The field points to: ./dist/custom-elements.json
// Via direct import
import cem from "@shopify/polaris-types/custom-elements";