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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@iuzairaslam/react-adaptive-text

v1.0.5

Published

Readable text on any background—WCAG & APCA aware React components and color helpers (TypeScript).

Downloads

59

Readme

react-adaptive-text

npm package: @iuzairaslam/react-adaptive-text

npm CI

react-adaptive-text — readable text on any background

You pick a background color; this library picks a foreground color so the copy stays readable—without manually choosing white vs black on every surface. It uses WCAG-minded contrast math, with optional APCA when you want a more perceptual read.

  • AdaptiveText — text-style element that sets color from the background (and optional brand palette).
  • AdaptiveTextTheme — define background and algorithm once for a subtree.
  • useAdaptiveForegroundColor — the same resolution for icons, strokes, or custom markup.
  • Helpers — luminance, contrast ratio, APCA, palette selection (tests, tooling, or your own components).

TypeScript, no native binaries—React plus browser-friendly color parsing.

Install

npm install @iuzairaslam/react-adaptive-text

Basic usage

import { AdaptiveText } from '@iuzairaslam/react-adaptive-text';

export function Banner() {
  return (
    <div style={{ background: '#1a237e', padding: 12 }}>
      <AdaptiveText backgroundColor="#1a237e" style={{ fontSize: 18 }}>
        Hello
      </AdaptiveText>
    </div>
  );
}

Theme

import { AdaptiveTextTheme, AdaptiveText } from '@iuzairaslam/react-adaptive-text';

export function Card() {
  return (
    <AdaptiveTextTheme backgroundColor="#333" algorithm="wcag">
      <AdaptiveText as="h3" style={{ margin: 0, fontWeight: 700 }}>
        Title
      </AdaptiveText>
      <AdaptiveText as="p" style={{ margin: 0 }}>
        Subtitle
      </AdaptiveText>
    </AdaptiveTextTheme>
  );
}

Palette

import { AdaptiveText, ContrastAlgorithm } from '@iuzairaslam/react-adaptive-text';

const brand = ['#ff9800', '#eeeeee', '#ffeb3b'];

export function BrandLine() {
  return (
    <AdaptiveText
      backgroundColor="#000000"
      palette={brand}
      algorithm={ContrastAlgorithm.apca}
    >
      Brand text
    </AdaptiveText>
  );
}

Notes

  • Pass colors as CSS strings: hex and rgb() / rgba() work everywhere; in the browser, named colors usually work too.
  • By default AdaptiveText renders a span. Use as="p", as="h1", etc. when you need semantic headings or paragraphs.
  • If you set style.color yourself, that always wins—useful when you intentionally override the automatic choice.

Repository

Issues and source: github.com/iuzairaslam/react-adaptive-text.

Development

npm install
npm test
npm run build

Try the included Vite example (interactive demos):

npm run dev:example