Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@miraidesigns/button

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@miraidesigns/button

Mirai Designs Framework: Button module

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Buttons

Buttons allow users to take actions with a single click or tap.


HTML

<button class="mdf-button">
    Button
</button>

Sass

// Include default styles without configuration
@forward '@miraidesigns/button/styles';
// Configure appearance
@use '@miraidesigns/button' with (
    $variable: value
);

@include button.styles();

Examples

Some basic examples on how the module can be used.

Icons

Icons can help give more meaning or emphasis to your button.

<!-- Leading icon -->
<button class="mdf-button mdf-button--leading-icon">
    <svg class="mdf-icon" viewBox="0 0 24 24" aria-hidden="true">
        <use href="icons.svg#favorite"></use>
    </svg>

    Favorite
</button>

<!-- Trailing icon -->
<button class="mdf-button mdf-button--trailing-icon">
    Favorite

    <svg class="mdf-icon" viewBox="0 0 24 24" aria-hidden="true">
        <use href="icons.svg#favorite"></use>
    </svg>
</button>

Implementation

Classes

NameTypeDescription
mdf-buttonParentApply basic styling to a button element
mdf-button--borderedModifierAdd a border to the button
mdf-button--filled ModifierFill the button with the brand color
mdf-button--smallModifierReduced the height and padding of the button
mdf-button--largeModifierIncrease the height and padding of the button
mdf-button--blockModifierStretches the button to width of its parent
mdf-button--block-responsiveModifierStretches the button to width of its parent (only on small devices)
mdf-button--leading-iconModifierAdjust spacing for the leading icon
mdf-button--trailing-iconModifierAdjust spacing for the trailing icon
mdf-button--iconModifierIcon only button
mdf-button--raisedModifierElevate button by adding a shadow
mdf-button--no-hoverModifierRemove the button hover effect

Toggles

A group of buttons where only one option can be active at a time.


HTML

<div class="mdf-toggles">
    <button class="mdf-button mdf-button--toggle" data-toggle-callback="callback1" aria-pressed="false" aria-label="Toggle 1">
        <svg class="mdf-icon" viewBox="0 0 24 24" aria-hidden="true">
            <use href="icons.svg#add"></use>
        </svg>
    </button>

    <button class="mdf-button mdf-button--toggle mdf-button--active" data-toggle-callback="callback2" aria-pressed="true" aria-label="Toggle 2">
        <svg class="mdf-icon" viewBox="0 0 24 24" aria-hidden="true">
            <use href="icons.svg#favorite"></use>
        </svg>
    </button>

    <button class="mdf-button mdf-button--toggle" data-toggle-callback="callback3" aria-pressed="false" aria-label="Toggle 3">
        <svg class="mdf-icon" viewBox="0 0 24 24" aria-hidden="true">
            <use href="icons.svg#clear"></use>
        </svg>
    </button>
</div>

TypeScript

import { MDFToggles } from '@miraidesigns/button';

new MDFToggles(document.querySelector('.mdf-toggles'), {
	callback1: () => {
		console.log('Pressed toggle 1');
	},
	callback2: () => {
		console.log('Pressed toggle 2');
	},
	callback3: () => {
		console.log('Pressed toggle 3');
	},
});

Implementation

Attributes

Please see the WAI-ARIA page for attributes and best practices regarding button toggles.

NameElementDescription
data-toggle-callback<button>The name of the callback associated with the toggle

Classes

NameTypeDescription
mdf-togglesParentContains the toggle elements
mdf-button--toggleChild / ModifierToggle button element. Child to .mdf-toggles
mdf-button--activeModifierSet toggle as active

Events

NameDataDescription
MDFToggle:changed{callback: string, index: number, toggle: HTMLButtonElement}Fires whenever the active toggle element changes. Includes the callback name, the index and the element itself

Properties

NameTypeDescription
.containerHTMLElementReturns the toggles container element
.togglesHTMLButtonElement[]Returns an Array of all toggle elements
.callbacksRecord<string, () => void>Returns an Object holding the toggle callbacks
.getToggle(index)(number): HTMLButtonElementReturns the toggle button element with the given index
.getActiveToggle()(): HTMLButtonElementReturns the currently active toggle element
.activateToggle(elem)(HTMLButtonElement): voidActivate the given toggle element

Options

NameTypeDefaultDescription
callbacks Record<string, () => void>nullObject containing the toggle callbacks

Keywords

FAQs

Package last updated on 13 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc