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

@tournant/switch-button

v0.1.4

Published

An accessible implementation of two-state switch buttons

Downloads

10

Readme

@tournant/switch-button

Installation

You can install the component using NPM or Yarn.

npm install @tournant/switch-button --save

If you use Yarn:

yarn add @tournant/switch-button

Once the component is installed you need to import it wherever you want to use it.

import TournantSwitchButton from '@tournant/switch-button'

Don’t forget to add it to the registered components (been there, done that):

components: {
  TournantSwitchButton,
  // ... all the other amazing components
}

Usage

Use this switch button, or toggle button as they are sometimes called, to implement a setting where you need literally an on-off switch (think: dark mode). Read here more about the decision to not implement it with a checkbox input.

Props

Use the value prop to set the switch button's state:

<tournant-switch-button value="true">Tournant awesomeness</tournant-switch-button>

To use <tournant-switch-button> as a controlled component, use the v-model attribute to bind it:

<tournant-switch-button v-model="pidgeon">Notify me by carrier pidgeon</tournant-switch-button>

To supply a both visual and programmatically determined label for your switch button instance use the default slot like this:

<tournant-switch-button>Dark mode</tournant-switch-button>

Other visually perceivable texts are available: the on-label prop (default value: "On", type String) labels the "on" state, whereas – surprisingly – the off-label prop (default value: "Off", type String) labels the "off" state:

<tournant-switch-button onLabel="An" offLabel="Aus">Kontrastmodus</tournant-switch-button>

Styles

The component exposes the following CSS classes for its parts:

| Classname | Element | | ------------------------------- | -------------------------------------------- | | t-ui-switch-button | Root | | t-ui-switch-button__button | The button itself | | t-ui-switch-button__label | The visual label | | t-ui-switch-button_\text | Generic container for the visual state label | | t-ui-switch-button_\text--on | Visual state label for "on" state | | t-ui-switch-button_\text-off | Visual state label for "off" state |

Bugs & Enhancements

If you found a bug, please create a bug ticket.

For enhancements please refer to the contributing guidelines.