2.1.0 • Published 9 months ago

vue-toggles v2.1.0

Weekly downloads
295
License
MIT
Repository
github
Last release
9 months ago

Introduction

Vue Toggles comes out of the box with accessibility support for:

  • aria-checked depending on state
  • aria-readonly if the toggle is disabled
  • prefers-reduced-motion if the user has requested any type of motion reduction [prefers-reduced-motion]

Accessibility

What's left for you, when it comes to accessibility, is labeling the toggle correctly. This is either done by:

  • A <label for="example-id">Toggle description</label> followed by the toggle component <VueToggles id="example-id" />
  • Or an aria-label, for example <VueToggles aria-label="Toggle description" />. Remember, you still need a visual text description of what the toggle does

The focus-style is also left up to you — which you shouldn't remove. If you think the default is ugly, style it yourself!

Installation

npm i vue-toggles

Import component

import { VueToggles } from "vue-toggles";

Import types

import { type VueTogglesProps } from "vue-toggles";

Usage

The toggle is very easy to use out of the box. The bare minimum for it to work is a @click-function and a :value-prop.

<VueToggles :value="example" @click="example = !example" />

Or if you prefer the v-model-syntax:

<VueToggles v-model="example" />

Options

You can also add more props to customize things like color and width/height.

<VueToggles
  :value="value"
  :height="30"
  :width="90"
  checkedText="On"
  uncheckedText="Off"
  checkedBg="#b4d455"
  uncheckedBg="lightgrey"
  @click="value = !value"
/>

Properties

NameTypeDefaultDescription
valueBooleanfalseInitial state of the toggle button
disabledBooleanfalseToggle does not react on mouse or keyboard events
reverseBooleanfalseReverse toggle to Right to Left
heightString, Number25Height of the toggle in px
widthString, Number75Width of the toggle in px
dotColorString#ffffffColor of the toggle dot
uncheckedBgString#939393Background color when the toggle is unchecked
checkedBgString#5850ecBackground color when the toggle is checked
uncheckedTextColorString#ffffffText color when the toggle is unchecked
checkedTextColorString#ffffffText color when the toggle is checked
uncheckedTextString""Optional text when the toggle is unchecked
checkedTextString""Optional text when the toggle is checked
fontSizeString12Font size in px
fontWeightStringnormalFont weight

Vue 2 support

If you're looking for Vue 2 support, the 1.1.4version is available here.

License

MIT

2.0.0

9 months ago

2.1.0

9 months ago

3.0.0-beta.5

3 years ago

1.1.4

3 years ago

3.0.0-beta.1

3 years ago

3.0.0-beta.0

3 years ago

3.0.0-beta.3

3 years ago

3.0.0-beta.2

3 years ago

3.0.0-beta.4

3 years ago

1.1.1-beta.2

3 years ago

1.1.1-beta.3

3 years ago

1.1.1-beta.0

3 years ago

1.1.1-beta.1

3 years ago

1.1.3

3 years ago

1.1.1

3 years ago

1.1.2

3 years ago

1.1.0-beta.3

4 years ago

1.1.0

4 years ago

1.1.0-beta.2

4 years ago

1.1.0-beta.1

4 years ago

1.1.0-beta.0

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.3-beta.6

4 years ago

1.0.3-beta.4

4 years ago

1.0.3-beta.3

4 years ago

1.0.3-beta.5

4 years ago

1.0.3-beta.0

4 years ago

1.0.3-beta.2

4 years ago

1.0.3-beta.1

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.7.6

4 years ago

0.7.6-beta.3

4 years ago

0.7.6-beta.2

4 years ago

0.7.6-beta.1

4 years ago

0.7.6-beta.0

4 years ago

0.7.5

4 years ago

0.7.5-beta.2

4 years ago

0.7.5-beta.1

4 years ago

0.7.5-beta.0

4 years ago

0.7.4

4 years ago

0.7.3

4 years ago

0.7.2-beta.0

4 years ago

0.7.3-beta.0

4 years ago

0.7.2

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.4

4 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.4.4

4 years ago

0.5.0

4 years ago

0.6.1

4 years ago

0.4.3

4 years ago

0.6.0

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.9

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago