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
messageStylesin your component styles to get the standard message look and its CSS custom properties.
Properties
- message: String. Message displayed below the field.
- errored: Boolean. When true, the message is displayed with the error style.
Methods
- clearError(): clears the message and the error state.
Getters
- messageTemplate: Lit template that renders the message (
<div class="message">), adding theerrored-msgclass whenerroredis true. Renders nothing when there is no message.
Implementations of DileFieldMessage
- dile-input (and the components that extend it)
- dile-input-message
dile-components