npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dev.mohe/mwc-fab

v0.19.3

Published

Material design floating action button component

Downloads

15

Readme

<mwc-fab> Published on npm

IMPORTANT: The Material Web Components are a work in progress and subject to major changes until 1.0 release.

A floating action button (FAB) represents the primary action of a screen.

Material Design Guidelines: Floating Action Button

Demo

Installation

npm install @dev.mohe/mwc-fab

NOTE: The Material Web Components are distributed as ES2017 JavaScript Modules, and use the Custom Elements API. They are compatible with all modern browsers including Chrome, Firefox, Safari, Edge, and IE11, but an additional tooling step is required to resolve bare module specifiers, as well as transpilation and polyfills for IE11. See here for detailed instructions.

Example usage

Standard

<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons&display=block">

<mwc-fab icon="edit"></mwc-fab>

<script type="module">
  import '@dev.mohe/mwc-fab';
  const fab = document.querySelector('mwc-fab');
  fab.addEventListener('click', () => {
    edit();
  });
</script>

Standard - slotted

<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons&display=block">

<mwc-fab label="edit">
  <mwc-icon slot="icon">edit</mwc-icon>
</mwc-fab>

<script type="module">
  import '@dev.mohe/mwc-fab';
  import '@dev.mohe/mwc-icon';
</script>

Note: label should still be set for button accessibility purposes.

Mini

<mwc-fab mini icon="add"></mwc-fab>

Extended

<mwc-fab extended icon="shopping_cart" label="Add to cart"></mwc-fab>

Customize colors

mwc-fab {
  --mdc-theme-secondary: white;
  --mdc-theme-on-secondary: black;
}

API

Slots

| Name | Description | -------- | --- | icon | An icon to be slotted into the fab. Note: the label property should still be set for button accessibility.

Properties/Attributes

| Name | Type | Description | --------------- | --------- |------------ | icon | string | The icon to display. | label | string | The label to display when using the extended layout, and the aria-label attribute in all layouts. | mini | boolean | Modifies the FAB to be a smaller size, for use on smaller screens. Defaults to false. | reducedTouchTarget | boolean | Sets the minimum touch target of the default-sized mini fab to recommended 48x48px. | extended | boolean | Enable the extended layout which includes a text label. Defaults to false. | showIconAtEnd | boolean | When in the extended layout, position the icon after the label, instead of before. Defaults to false.

Methods

None

Events

None

CSS Custom Properties

Name | Default | Description -------------------------- | -----------------------------------| ----------- --mdc-fab-box-shadow | mdc elevation 6, 8, 12 | Sets the box shadow of the fab. Elevation 6 when idle, 8 when focused or hovered, and 12 when active.

Elevation values

| Elevation Level | CSS Value | ---- | --- | 6 | 0px 3px 5px -1px rgba(0, 0, 0, 0.2), 0px 6px 10px 0px rgba(0, 0, 0, 0.14), 0px 1px 18px 0px rgba(0, 0, 0, 0.12) | 8 | 0px 5px 5px -3px rgba(0, 0, 0, 0.2), 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12) | 12 | 0px 7px 8px -4px rgba(0, 0, 0, 0.2), 0px 12px 17px 2px rgba(0, 0, 0, 0.14), 0px 5px 22px 4px rgba(0, 0, 0, 0.12)

Global Custom Properties

This component exposes the following global theming custom properties.

| Name | Description | ------------------------------------ | ----------- | --mdc-icon-font | Font to use for the icon. | --mdc-theme-secondary | Background color of the FAB. | --mdc-theme-on-secondary | Foreground color of the label and icon.

Additional references