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

custom-selection

v1.1.3

Published

Add custom ::selection css pseudo-element to website using data attributes all so you can improve your websites look and feel

Downloads

17

Readme

Verified on Openbase

Add custom ::selection css pseudo-element to website using data attributes all so you can improve your websites look and feel

Installation

⚠️ Custom CSS Selection is a controversial practice that can cause usability, accessibility, and performance issues. Don't override selected text styles for purely aesthetic reasons — users can customize them to suit their needs. For people experiencing cognitive concerns or who are less technologically literate, unexpected changes to selection styles may hurt their understanding of the functionality. If overridden, it is important to ensure that the contrast ratio between the text and background colors of the selection is high enough that people experiencing low vision conditions can read it.

CDN

Inside <body> closing tag

<!-- Custom Selection -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/custom-selection.core.min.js"></script>

Usage

Basic

With simple detection.

HTML

<body data-selection data-selection-color="1a1a1a" data-selection-text-color="#fffff"></body>

Element Attributes

| Attribute | Values | Description | | ------------------------------------------ | ---------- | ------------------------------------------------------------ | | data-selection | | Initialises JavaScript | | data-selection-color | hex code | https://img.shields.io/badge/hex-value-blue Changes text selection background color | | data-selection-text-color | hex code | https://img.shields.io/badge/hex-value-blue Changes text selection text color | | data-selection-text-stroke | boolean | https://img.shields.io/badge/-coming%20soon-inactive Initialises text stroke CSS value | | data-selection-text-stroke-color | hex code | https://img.shields.io/badge/-coming%20soon-inactive https://img.shields.io/badge/hex-value-blue Changes text selection stroke color | | data-selection-text-stroke-width | string | https://img.shields.io/badge/-coming%20soon-inactive Changes selection stroke width | | data-selection-text-stroke-fill-color | hex code | https://img.shields.io/badge/-coming%20soon-inactive https://img.shields.io/badge/hex-value-blue Changes text selection stroke fill color | | data-selection-text-decoration | boolean | https://img.shields.io/badge/-coming%20soon-inactive Initialises text decoration CSS value | | data-selection-text-decoration-color | hex code | https://img.shields.io/badge/-coming%20soon-inactive https://img.shields.io/badge/hex-value-blue Changes text decoration color | | data-selection-text-decoration-line | string | https://img.shields.io/badge/-coming%20soon-inactive Add line decorations using underline , overline & line-through | | data-selection-text-decoration-style | string | https://img.shields.io/badge/-coming%20soon-inactive Add line styles using solid, double, dotted, dashed & wavy | | data-selection-text-decoration-thickness | string | https://img.shields.io/badge/-coming%20soon-inactive |

Demo

demo

Values Used

| attribute | value | | :-------------------------- | :-------: | | data-selection | - | | data-selection-color | #f7f33a | | data-selection-text-color | #cba6d6 |

Final Element
<body data-selection data-selection-color="#f7f33a" data-selection-text-color="#cba6d6"></body>

Browser support

source : mdn web docs supportFull = https://img.shields.io/badge/-Full%20Support-success

supportRequires a vendor prefix or different name for use = https://img.shields.io/badge/-Some%20Support-important

supportNo = https://img.shields.io/badge/-No%20Support-critical

| | Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on iOS | Samsung Internet | WebView Android | | :------------------------- | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | | ::selection | https://img.shields.io/badge/-%20Version%201-success | https://img.shields.io/badge/-%20Version%2012-success | https://img.shields.io/badge/-%20Version%2062-success | https://img.shields.io/badge/-%20Version%209.5-success | https://img.shields.io/badge/-%20Version%201.1-success | https://img.shields.io/badge/-%20Version%2018-success | https://img.shields.io/badge/-%20Version%2062-success | https://img.shields.io/badge/-%20Version%2014-success | https://img.shields.io/badge/-No%20Support-critical | https://img.shields.io/badge/-%20Version%201.0-success | https://img.shields.io/badge/-%20Version%2037-success | | dataset | https://img.shields.io/badge/-%20Version%208-success | https://img.shields.io/badge/-%20Version%2012-success | https://img.shields.io/badge/-%20Version%206-success | https://img.shields.io/badge/-%20Version%2011-success | https://img.shields.io/badge/-%20Version%205.1-success | https://img.shields.io/badge/-%20Version%2018-success | https://img.shields.io/badge/-%20Version%206-success | https://img.shields.io/badge/-%20Version%2011-success | https://img.shields.io/badge/-%20Version%205-success | https://img.shields.io/badge/-%20Version%201.1-success | https://img.shields.io/badge/-%20Version%203-success | | custom-selection.core.js | https://img.shields.io/badge/-%20Version%201-success | https://img.shields.io/badge/-%20Version%2012-success | https://img.shields.io/badge/-%20Version%2062-success | https://img.shields.io/badge/-%20Version%209.5-success | https://img.shields.io/badge/-%20Version%201.1-success | https://img.shields.io/badge/-%20Version%2018-success | https://img.shields.io/badge/-%20Version%2062-success | https://img.shields.io/badge/-%20Version%2014-success | https://img.shields.io/badge/-No%20Support-critical | https://img.shields.io/badge/-%20Version%201.0-success | https://img.shields.io/badge/-%20Version%2037-success |

Useful Links

mdn web docs