Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/vaadin-component-factory/vcf-dark-mode-switch

Vaadin Component Factory Dark Mode Switch
https://github.com/vaadin-component-factory/vcf-dark-mode-switch

dark-mode dark-mode-switch dark-mode-toggle polymer3 vaadin webcomponent

Last synced: about 1 month ago
JSON representation

Vaadin Component Factory Dark Mode Switch

Awesome Lists containing this project

README

        

# <vcf-dark-mode-switch>

## Demo

https://vcf-dark-mode-switch.netlify.com/

## Installation

Install `vcf-dark-mode-switch`:

```sh
npm i @vaadin-component-factory/vcf-dark-mode-switch --save
```

## Usage

Once installed, import it in your application:

```js
import '@vaadin-component-factory/vcf-dark-mode-switch';
```

And use it:

```html

```

You can provide a label via a `label` attribute.

By toggling the dark mode switch:

- A `theme="dark"` attribute will be toggled on the `html` tag.
- The user's preference will be persisted on `localStorage` with a key `vcf-dark-mode`.
- On page refresh, the persisted user's preference will be applied.

**Note that the component applies dark mode preference from the OS level if the user's preference is not set.**

## Running demo

1. Fork the `vcf-dark-mode-switch` repository and clone it locally.

1. Make sure you have [npm](https://www.npmjs.com/) installed.

1. When in the `vcf-dark-mode-switch` directory, run `npm install` to install dependencies.

1. Run `npm start` to open the demo.

## Contributing

To contribute to the component, please read [the guideline](https://github.com/vaadin/vaadin-core/blob/master/CONTRIBUTING.md) first.

## License

Apache License 2.0