Kinds

Create reusable, standardized configurations for extensions, helping to streamline development, ensure consistency, and reduce duplication.

A Kind is a preset configuration that extensions inherit for consistency. It reduces redundancy by defining default properties. This simplifies maintenance for extensions sharing similar functionality.

Every Kind links to a specific extension type. Extensions of that type referencing a Kind automatically inherit its settings. This ensures uniformity across different extensions.

Benefits of Using a Kind

  • Reduces redundancy – Defines common settings once for reuse across extensions.

  • Ensures consistency – Extensions using the same Kind follow a standardized structure.

  • Simplifies definitions – Extensions inherit predefined properties to reduce manual configuration.

Kind Registration

Register a Kind using the standard extension method. The key properties defining a Kind registration are:

  • type: Always set this to kind.

  • alias: A unique identifier for the Kind.

  • matchType: Specifies the applicable extension type.

  • matchKind: Defines the Kind alias referenced by extensions.

  • manifest: Contains preset values for inheritance.

Example: Registering a Button Kind for Header Apps

This example registers a Button Kind for Header Apps. It provides a preset button configuration for other extensions to reuse.

Properties:

  • type is 'kind', registering it as a Kind extension.

  • matchType is 'headerApp', targeting Header App extensions.

  • matchKind is 'button', serving as the Kind's alias.

  • The manifest holds default properties, like elementName, for inheritance.

Using the Kind in Other Extensions

Use a Kind by setting the type and kind properties. The extension then automatically inherits the Kind's properties.

Example: Header App Extension Using the Button Kind

Here, the extension uses kind: 'button' to inherit elementName. It also adds custom metadata to further customize behavior or appearance.

Custom Kind Example

The code below demonstrates how to create a custom kind. This Kind extension will allow extension developers to display welcome messages in the header that will greet backoffice users.

Custom Header App Created Using a Kind

Create the Kind Extension

Start by defining and registering a new Kind extension. Select a unique name for the matchKind and manifest.elementName properties.

Create a Custom Component for welcome-header-app-message

Create a custom component to render our welcome message out to the backoffice user. The manifest.elementName property in the kind manifest should match the value of @customElement and declare global { ... declarations.

Derive Header Apps Using the Custom Kind Extension

Use the previously defined Kind extension, welcomeHeaderAppMessage to create messages to display to the user for each day of the week. Properties such as manifest.elementName that are defined in the welcomeHeaderAppMessage kind extension will fall through to derived extensions. These properties do not need to be redefined in extensions that inherit from the welcomeHeaderAppMessage kind.

  • For each derived extension, the kind property must match the matchKind property on welcomeHeaderAppMessage.

  • The type property must also match the matchType property on welcomeHeaderAppMessage.

  • Use element to import the custom component.

Register the Derived Extension

Use any standard practice to register the derived extension, in this case thursdayWelcomeMessageHeaderAppInstance is registered dynamically in an entrypoint.

Referencing the Kind ensures consistency by inheriting shared properties. This also simplifies updating configurations across multiple extensions.

Last updated

Was this helpful?