logo dile-components dile-components

DileFieldMessage

This mixin provides the common features to display a feedback or validation message in a form element.

It is compatible with the DileFormMixin, which sets message and errored on form elements through its showError() and clearErrors() methods.

Installation

npm i @dile/ui

Usage

import { LitElement, html } from 'lit';
import { DileFieldMessage } from '@dile/ui/mixins/form';
import { messageStyles } from '@dile/ui/components/input';

class MyField extends DileFieldMessage(LitElement) {
  static get styles() {
    return [messageStyles];
  }

  render() {
    return html`
      <!-- your field interface -->
      ${this.messageTemplate}
    `;
  }
}

The mixin doesn't add styles by itself. Include messageStyles in your component styles to get the standard message look and its CSS custom properties.

Properties

Methods

Getters

Implementations of DileFieldMessage