Template

A beautiful button that can make your life easier and also looks good.

Import
the javascript logo
import { Button } from "@schukai/monster/source/components/form/button.mjs";
Source
the git logo
Package
the npm logo
Since
1.5.0
click me!

Introduction

This is the Monster Button web component. More than just a button, this component is the gateway to an interactive and engaging user experience that integrates seamlessly into various web applications. Whether you are developing a simple website or a complex enterprise application, the Monster Button is designed to increase 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 button to match the design of your brand or application to improve visual consistency.
  • Accessibility: Designed with accessibility in mind to ensure all users have a seamless experience regardless of their browsing context.
  • Ripple effect: A subtle touch feedback effect that enhances tactile interaction with the button and makes users' actions more enjoyable.
  • Programmatic Control: Provides methods such as click, focus, and blur to programmatically control the behavior of the button, giving developers flexibility.

Improving the user experience

The Monster Button goes beyond the traditional functions of a button to provide an enhanced and interactive user experience. Its ripple effect combined with 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 show a positive impact on user commitment and satisfaction.

Efficiency in the development process

Integrating the Monster Button into your development process is easy. Its compatibility with standard web technologies and ease of customization allow for seamless integration with your existing tools and libraries. Whether you are working on a small project or a large application, Monster Button's modular design guarantees easy integration that streamlines your development process and increases your productivity.

Button Simple

This is a simple button example. It is a button with the text "click me!". Nothing more, nothing less.

click me!

Javascript

import "@schukai/monster/source/components/form/button.mjs";

HTML

<monster-button>click me!</monster-button>

Stylesheet

/** no additional stylesheet is defined **/

Button With Click Event

This is a simple button example with click handling. It is a button with the text "click me!". When you click on the button, the text "Button clicked!" will be displayed below the button. The text will be removed after 2 seconds.

You can either attach a classic event handler to the element, or you can use the actions.click option.

click me!

Javascript

import "@schukai/monster/source/components/form/button.mjs";

HTML

<monster-button id="eeSh6A-button">click me!</monster-button>

<div id="eeSh6A-result" style="margin-top: 20px;display: flex;align-items: center;justify-content: center;">

</div>

<script>

    // watch for the DOMContentLoaded event
    window.addEventListener('DOMContentLoaded', function () {
        
        // get the button element and set a click event callback
        document.getElementById('eeSh6A-button').setOption("actions.click", function () {
            
            // set a text to the result element
            document.getElementById('eeSh6A-result').innerHTML = 'Button clicked!';
            
            // Reset the result after 2 seconds.
            // This is only there so that you can click more often.
            setTimeout(function () {
                document.getElementById('eeSh6A-result').innerHTML = '';
            }, 2000);
        });

    });

</script>

Stylesheet

/** no additional stylesheet is defined **/
DESIGN22333dd

HTML Structure

<monster-button></monster-button>

JavaScript Initialization

const element = document.createElement('monster-button');
document.body.appendChild(element);

Exported

Button

Options

Option
Type
Default
Description
templates
object
Template definitions
templates.main
string
undefined
Main template
labels
object
Labels
labels.button
string
<slot></slot>
actions
object
Callbacks
actions.click
string
throw Error
classes
object
CSS classes
classes.button
string
monster-button-primary
disabled
boolean
false
effects
object
Effects
effects.ripple
boolean
true
type
string
button
havior of the button. Possible values are: submit, reset, button

Properties and Attributes

  • 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

Static methods

formAssociated()
Returns
  • {boolean}
getCSSStyleSheet()
Returns
  • {CSSStyleSheet[]}
getTag()
Returns
  • {string}
instanceSymbol()2.1.0
Returns
  • {symbol}
This method is called by the instanceof operator.
observedAttributes()
Returns
  • {string[]}
This method determines which attributes are to be monitored by attributeChangedCallback().

Lifecycle methods

assembleMethodSymbol()
Returns
  • {Button}

Other methods

blur()
The Button.blur() method removes focus from the internal button element.
click()3.27.0
The Button.click() method simulates a click on the internal button element.
focus(options)3.27.0
Parameters
  • options {object}: options
The Button.focus() method sets focus on the internal button element.
value()
Returns
  • {string}: value of the button
The current value of the button.

e = document.querySelector('monster-button');
console.log(e.value)

value(value)
Parameters
  • value {string}: value
Returns
  • {void}
Throws
  • {Error} unsupported type
Set the value of the button.

e = document.querySelector('monster-button');
e.value=1


Events

The component emits the following events:

  • monster-button-clicked this event is triggered when the button is clicked. It contains the field {button} with the button instance.

For more information on how to handle events, see the mdn documentation.

The current width of the area is too small to display the content correctly.