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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@banegasn/m3-radio-button

v1.0.1

Published

Material Design 3 radio button web component

Readme

@banegasn/m3-radio-button

Material Design 3 Radio Button web component. Radio buttons allow users to select a single option from a group of options, following Material Design 3 specifications.

Installation

npm install @banegasn/m3-radio-button
# or
pnpm add @banegasn/m3-radio-button
# or
yarn add @banegasn/m3-radio-button

Usage

Basic Example

<m3-radio-button name="option" value="1"></m3-radio-button>
<m3-radio-button name="option" value="2" checked></m3-radio-button>
<m3-radio-button name="option" value="3" disabled></m3-radio-button>

Radio Group

Radio buttons with the same name attribute form a group where only one can be selected:

<m3-radio-button name="theme" value="light" checked>Light</m3-radio-button>
<m3-radio-button name="theme" value="dark">Dark</m3-radio-button>
<m3-radio-button name="theme" value="auto">Auto</m3-radio-button>

With JavaScript

import '@banegasn/m3-radio-button';

const radioButtons = document.querySelectorAll('m3-radio-button[name="option"]');
radioButtons.forEach(radio => {
  radio.addEventListener('radio-change', (e) => {
    console.log('Selected:', e.detail.value);
  });
});

With React

import '@banegasn/m3-radio-button';

function App() {
  const [selected, setSelected] = useState('option1');

  return (
    <>
      <m3-radio-button
        name="group"
        value="option1"
        checked={selected === 'option1'}
        onRadioChange={(e) => setSelected(e.detail.value)}
      />
      <m3-radio-button
        name="group"
        value="option2"
        checked={selected === 'option2'}
        onRadioChange={(e) => setSelected(e.detail.value)}
      />
    </>
  );
}

With Angular

import '@banegasn/m3-radio-button';

@Component({
  template: `
    <m3-radio-button
      name="group"
      value="option1"
      [checked]="selected === 'option1'"
      (radio-change)="onRadioChange($event)"
    ></m3-radio-button>
  `
})
export class MyComponent {
  selected = 'option1';

  onRadioChange(event: CustomEvent) {
    this.selected = event.detail.value;
  }
}

With Vue

<template>
  <m3-radio-button
    name="group"
    value="option1"
    :checked="selected === 'option1'"
    @radio-change="onRadioChange"
  />
</template>

<script setup>
import '@banegasn/m3-radio-button';
import { ref } from 'vue';

const selected = ref('option1');

const onRadioChange = (event) => {
  selected.value = event.detail.value;
};
</script>

Properties

| Property | Type | Default | Description | |----------|------|---------|-------------| | checked | boolean | false | Whether the radio button is checked | | disabled | boolean | false | Disables the radio button | | name | string | null | Name attribute for radio group (required for grouping) | | value | string | null | Value attribute for form submission | | form | string | null | Form attribute to associate radio with a form | | aria-label | string | null | ARIA label for accessibility | | aria-labelledby | string | null | ARIA labelled by for accessibility |

Events

| Event | Detail | Description | |-------|--------|-------------| | radio-change | { checked: boolean, name: string \| null, value: string \| null } | Fired when the radio button state changes |

Methods

| Method | Description | |--------|-------------| | focus() | Focuses the radio button | | blur() | Removes focus from the radio button |

CSS Custom Properties

You can customize the radio button appearance using CSS custom properties:

m3-radio-button {
  --md-radio-size: 20px;
  --md-radio-outer-size: 20px;
  --md-radio-inner-size: 10px;
  --md-radio-ripple-size: 40px;
  --md-sys-color-primary: #6750a4;
  --md-sys-color-on-surface: #1d1b20;
}

Radio Groups

Radio buttons with the same name attribute automatically form a group. When one radio button in a group is selected, all others in the same group are automatically deselected.

Accessibility

The radio button component follows Material Design 3 accessibility guidelines:

  • Uses proper ARIA attributes (role="radio", aria-checked, aria-disabled)
  • Supports keyboard navigation (Space and Enter keys)
  • Provides focus indicators
  • Supports screen readers with aria-label and aria-labelledby
  • Properly manages radio groups

Browser Support

  • Chrome/Edge (latest)
  • Firefox (latest)
  • Safari (latest)
  • All modern browsers that support Web Components

License

MIT