New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@m3e/button

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@m3e/button

Button for M3E

latest
Source
npmnpm
Version
1.3.1
Version published
Maintainers
1
Created
Source

@m3e/button

The m3e-button component is a semantic, expressive UI primitive users interact with to perform an action. Designed according to Material Design 3 guidelines, it supports five visual variants, specified using the variant attribute—filled, tonal, elevated, outlined, and text—each with dynamic elevation, shape morphing, and adaptive color theming. The component responds to interaction states (hover, focus, press, disabled) with smooth motion transitions, ensuring emotional clarity and visual hierarchy.

The component is accessible by default, with ARIA roles, contrast-safe color tokens, and strong focus indicators. It supports optional icons and states for binary actions. When using m3e-icon for icons, filled is automatically set based on the selected state of a toggle button. It can also function as a link or be used to submit form data.

Native disabled <button> elements cannot receive focus. This can be problematic in some cases because it can prevent you from telling the user why the button is disabled. You can use the disabled-interactive attribute to style a m3e-button as disabled but allow for it to receive focus. The button will have aria-disabled="true" for assistive technology.

This package is part of M3E monorepo, a unified suite of Material 3 web components. Explore the docs to see them in action.

📦 Installation

npm install @m3e/button

💻 Editor Integration

This package includes a Custom Elements Manifest to support enhanced editor tooling and developer experience.

Visual Studio Code

To enable autocomplete and hover documentation for @m3e/button, install the Custom Elements Manifest Language Server extension. It will automatically detect the manifest bundled with this package and surface tag names, attributes, slots, and events in supported files.

Alternately, you can explicitly reference the html-custom-data.json and css-custom-data.json in your workspace settings:

{
  "html.customData": ["./node_modules/@m3e/button/dist/html-custom-data.json"],
  "css.customData": ["./node_modules/@m3e/button/dist/css-custom-data.json"]
}

🚀 Native Module Support

This package uses JavaScript Modules. To use it directly in a browser without a bundler, use a module script similar to the following.

<script type="module" src="/node_modules/@m3e/button/dist/index.js"></script>

In addition, you must use an import map to include dependencies.

<script type="importmap">
  {
    "imports": {
      "lit": "https://cdn.jsdelivr.net/npm/lit@3.3.0/+esm",
      "@m3e/core": "/node_modules/@m3e/core/dist/index.js"
    }
  }
</script>

For production, use index.min.js for faster load times.

🗂️ Elements

  • m3e-button — A button users interact with to perform an action.

🧪 Examples

The following example illustrates changing the appearance from text (default) to tonal using the variant attribute.

<m3e-button variant="tonal">Tonal Button</m3e-button>

📖 API Reference

This section details the attributes, slots and CSS custom properties available for the m3e-button component.

⚙️ Attributes

AttributeTypeDefaultDescription
variant"elevated" | "filled" | "tonal" | "outlined" | "text""text"The appearance variant of the button.
shape"rounded" | "square""rounded"The shape of the button.
size"extra-small" | "small" | "medium" | "large" | "extra-large""small"The size of the button.
togglebooleanfalseWhether the button will toggle between selected and unselected states.
selectedbooleanfalseWhether the toggle button is selected.
disabledbooleanfalseWhether the element is disabled.
disabled-interactivebooleanfalseWhether the element is disabled and interactive.
type"button" | "submit" | "reset""button"The type of the element.
namestringThe name of the element, submitted as a pair with the element's value as part of form data, when the element is used to submit a form.
valuestringThe value associated with the element's name when it's submitted with form data.
hrefstringThe URL to which the link button points.
targetstringThe target of the link button.
relstringThe relationship between the target of the link button and the document.
downloadstringA value indicating whether the target of the link button will be downloaded, optionally specifying the new name of the file.

🧩 Slots

SlotDescription
(default)Renders button label/content.
iconRenders leading icon before label.
trailing-iconRenders trailing icon after label.
selectedRenders label when toggle button is selected.
selected-iconRenders icon before label when selected.

🎛️ CSS Custom Properties

🧱 Size Properties

All size variants (extra-small, small, medium, large, extra-large) support:

PropertyDescription
--m3e-button-[size]-container-heightHeight of the button container
--m3e-button-[size]-outline-thicknessOutline thickness
--m3e-button-[size]-label-text-font-sizeFont size for label
--m3e-button-[size]-label-text-font-weightFont weight for label
--m3e-button-[size]-label-text-line-heightLine height for label
--m3e-button-[size]-label-text-trackingLetter tracking for label
--m3e-button-[size]-icon-sizeIcon size
--m3e-button-[size]-shape-roundCorner radius for round shape
--m3e-button-[size]-shape-squareCorner radius for square shape
--m3e-button-[size]-selected-shape-roundCorner radius when selected (round)
--m3e-button-[size]-selected-shape-squareCorner radius when selected (square)
--m3e-button-[size]-shape-pressed-morphCorner radius when pressed
--m3e-button-[size]-leading-spaceSpace before icon/label
--m3e-button-[size]-trailing-spaceSpace after icon/label
--m3e-button-[size]-icon-label-spaceSpace between icon and label

🎨 Appearance Variant Properties

All appearance variants (filled, tonal, elevated, outlined, text) support the following properties (replace [variant] with the variant name):

PropertyDescription
--m3e-[variant]-button-label-text-colorLabel color
--m3e-[variant]-button-icon-colorIcon color
--m3e-[variant]-button-container-colorContainer background color
--m3e-[variant]-button-container-elevationElevation
--m3e-[variant]-button-outline-colorOutline color (outlined only)
--m3e-[variant]-button-outline-thicknessOutline thickness (outlined only)

🟫 State Properties

Each variant supports state properties for disabled, hover, focus, pressed, selected, and unselected. For each variant, the following properties are available (replace [variant] with the variant name):

PropertyDescription
--m3e-[variant]-button-disabled-label-text-colorLabel color when disabled
--m3e-[variant]-button-disabled-label-text-opacityLabel opacity when disabled
--m3e-[variant]-button-disabled-icon-colorIcon color when disabled
--m3e-[variant]-button-disabled-icon-opacityIcon opacity when disabled
--m3e-[variant]-button-disabled-container-colorContainer color when disabled
--m3e-[variant]-button-disabled-container-opacityContainer opacity when disabled
--m3e-[variant]-button-disabled-container-elevationElevation when disabled
--m3e-[variant]-button-hover-label-text-colorLabel color on hover
--m3e-[variant]-button-hover-icon-colorIcon color on hover
--m3e-[variant]-button-hover-state-layer-colorState layer color on hover
--m3e-[variant]-button-hover-state-layer-opacityState layer opacity on hover
--m3e-[variant]-button-hover-container-elevationElevation on hover
--m3e-[variant]-button-hover-outline-colorOutline color on hover (outlined only)
--m3e-[variant]-button-focus-label-text-colorLabel color on focus
--m3e-[variant]-button-focus-icon-colorIcon color on focus
--m3e-[variant]-button-focus-state-layer-colorState layer color on focus
--m3e-[variant]-button-focus-state-layer-opacityState layer opacity on focus
--m3e-[variant]-button-focus-container-elevationElevation on focus
--m3e-[variant]-button-focus-outline-colorOutline color on focus (outlined only)
--m3e-[variant]-button-pressed-label-text-colorLabel color on press
--m3e-[variant]-button-pressed-icon-colorIcon color on press
--m3e-[variant]-button-pressed-state-layer-colorState layer color on press
--m3e-[variant]-button-pressed-state-layer-opacityState layer opacity on press
--m3e-[variant]-button-pressed-container-elevationElevation on press
--m3e-[variant]-button-pressed-outline-colorOutline color on press (outlined only)

🟦 Selected/Unselected State Properties

For toggle buttons, each variant supports selected/unselected state properties:

PropertyDescription
--m3e-[variant]-button-selected-label-text-colorLabel color when selected
--m3e-[variant]-button-selected-icon-colorIcon color when selected
--m3e-[variant]-button-selected-container-colorContainer color when selected
--m3e-[variant]-button-selected-state-layer-colorState layer color when selected
--m3e-[variant]-button-unselected-label-text-colorLabel color when unselected
--m3e-[variant]-button-unselected-icon-colorIcon color when unselected
--m3e-[variant]-button-unselected-container-colorContainer color when unselected
--m3e-[variant]-button-unselected-state-layer-colorState layer color when unselected

🤝 Contributing

See the root monorepo CONTRIBUTING.md for guidelines on contributing to this package.

📄 License

This package is licensed under the MIT License.

Keywords

material design

FAQs

Package last updated on 20 Feb 2026

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