Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/rumkin/favicon-switcher

Make favicon react on media queries
https://github.com/rumkin/favicon-switcher

favicon site theming ui utils

Last synced: 3 months ago
JSON representation

Make favicon react on media queries

Awesome Lists containing this project

README

        

# Favicon Switcher

[Live preview](https://rumkin.github.io/favicon-switcher)

Light mode favicon example
Dark mode favicon example

Switches site's favicon by matching media queries. It could be used for
light/dark mode switching. Due to browsers don't support all Media Query
features in link tag, this module fixes it.

## Usage

Script doesn't require any setup or configuration and works like a polyfill.
The example below shows how to make dark/light mode icon switching.

Use the main library to automatically turn icon switching on:

```html

```

If you need more control to turn switching on and off use one of the next
module:

### UMD

Use with UMD:

```html

faviconSwitcher()
```

### ESM

Use as ES module:

```html

import initSwitcher from 'https://unpkg.com/[email protected]/dist/index.esm.js'

// Subscribe to media queries changing events
const unsubscribe = initSwitcher()
// Unsubscribe later on some condition. For example on page navigation.
unsubscribe()

```

## Complete example

```html






```

## License

MIT © [Rumkin](https://rumk.in)