Message
The message is a notification element that can be used to display messages to the user. Typically, it is only used in conjunction with the notify container.
import { Message } from "@schukai/monster/source/components/notify/message.mjs";Introduction
This is a versatile web component. More than just a simple UI element, this component serves as a key element for enhancing interactivity and engagement within various web applications. Whether you are developing a basic website or a complex enterprise-level application, this component is designed to improve user interaction and satisfaction.
Key Features
- Dynamic interaction: Users can interact with content dynamically, making the web experience more intuitive and user-centric.
- Customizable appearance: Customize the appearance of the component to match the design of your brand or application, ensuring visual consistency.
- Accessibility: Designed with accessibility in mind to ensure that all users have a seamless experience, regardless of their browsing environment.
- Visual feedback effect: Provides subtle touch feedback to enhance user interaction, making actions more responsive and engaging.
- Programmatic Control: Offers methods such as trigger, focus, and deactivate, allowing developers to control the component's behavior programmatically and offering greater flexibility.
Improving the user experience
This component goes beyond its traditional functionality to offer an enhanced and interactive user experience. The combination of visual feedback effects and dynamic interaction with content is not only visually appealing, but also provides clear and responsive feedback to user actions, making the web environment more intuitive and user-friendly.
These improvements are supported by user studies that demonstrate a positive impact on user engagement and satisfaction.
Efficiency in the development process
Integrating this component into your development process is straightforward. Its compatibility with standard web technologies and ease of customization ensure seamless integration with your existing tools and libraries. Whether you're working on a small project or a large-scale application, the modular design of this component guarantees easy integration, streamlining your development process and enhancing productivity.
Message
In this example, a message is displayed within the context of a notification container. For more details about the container, visit the notification container page.
Javascript
import '@schukai/monster/source/components/notify/notify.mjs';
const notify = document.querySelector('monster-notify');
notify.push(`This is a message`);HTML
<div>
<monster-notify></monster-notify>
</div>Stylesheet
/** no additional stylesheet is defined **/Component Design
The Message component is a child element of the Notify component, designed to display individual notification messages. It uses the Shadow DOM to encapsulate its structure and styling, ensuring isolation and consistency across different environments.
Each message consists of a content area and an optional close button, both of which can be styled and customized using exported parts and CSS variables.
Shadow DOM and Accessibility
The use of the Shadow DOM ensures that the internal structure of the Message component is isolated from external styles or scripts. This prevents unintended interference and maintains design integrity.
Accessibility is prioritized in the component's design. The close button is keyboard-navigable and provides semantic attributes to support screen readers and assistive technologies.
Customizing Through Exported Parts
The Message component allows customization of specific areas through exported parts. These parts enable developers to style the content and close button independently, while keeping the internal structure encapsulated.
Available Part Attributes
control: The main container for the message.message: The area that holds the entire message content and controls.content: The specific part for the message's textual content.remove: The close button for dismissing the message.
Example of customizing the message using CSS:
monster-notify-message::part(control) {
background-color: #f9f9f9;
padding: 12px;
border-radius: 8px;
}
monster-notify-message::part(content) {
font-size: 14px;
color: #333;
}
monster-notify-message::part(remove) {
width: 18px;
height: 18px;
background-color: #ff5555;
border-radius: 50%;
}
CSS Variables
The Message component provides a variety of CSS variables for flexible customization. These variables allow developers to adjust the design and appearance of the component without modifying its internal structure.
--monster-bg-color-primary-1: Sets the background color of the message.--monster-color-primary-1: Sets the text color of the message content and close button.--monster-z-index-modal-overlay: Adjusts the stacking order of the close button.
Example of using CSS variables to customize the design:
monster-notify-message {
--monster-bg-color-primary-1: #fffaf0;
--monster-color-primary-1: #444444;
--monster-z-index-modal-overlay: 1050;
}
Accessibility
The Message component supports accessibility through semantic structure and focusable controls. The close button is designed to be both keyboard and mouse accessible, and the content area supports text selection to enhance usability for all users.
HTML Structure
<monster-message></monster-message>JavaScript Initialization
const element = document.createElement('monster-message');
document.body.appendChild(element);Exported
MessageDerived from
CustomElementOptions
The Options listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class. Therefore, it inherits Options from these parent classes. If you cannot find a specific Options in this list, we recommend consulting the documentation of the CustomElement.
- since
- deprecated
Properties and Attributes
The Properties and Attributes listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class and ultimately from HTMLElement. Therefore, it inherits Properties and Attributes from these parent classes. If you cannot find a specific Properties and Attributes in this list, we recommend consulting the documentation of the CustomElement.
data-monster-options: Sets the configuration options for the collapse component when used as an HTML attribute.data-monster-option-[name]: Sets the value of the configuration option[name]for the collapse component when used as an HTML attribute.
Methods
The methods listed in this section are defined directly within the class. This class is derived from several parent classes, including the CustomElement class and ultimately from HTMLElement. Therefore, it inherits methods from these parent classes. If you cannot find a specific method in this list, we recommend consulting the documentation of the CustomElement.
Static methods
getCSSStyleSheet()- {CSSStyleSheet[]}
getTag()- {string}
Lifecycle methods
Lifecycle methods are called by the environment and are usually not intended to be called directly.
[assembleMethodSymbol]()- {Monster.Components.Notify.Message}
[initMethodSymbol]()connectedCallback()- {void}
disconnectedCallback()- {void}
Events
This component does not fire any public events. It may fire events that are inherited from its parent classes.