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

pixelfit

v2.0.1

Published

A lightweight and flexible screen adaptation library for mobile and large-screen devices.

Downloads

7

Readme

Pixelfit

A lightweight and flexible screen adaptation library for mobile and large-screen devices, supporting responsive scaling and px-rem conversion.

Features

  • Mobile adaptation: Automatically scales the root font size (rem) for mobile devices based on the design width.
  • Large screen adaptation: Adapts target DOM elements to fit large screen resolutions using transform scaling.
  • Utility methods: Includes px2rem and rem2px conversion utilities.
  • Type-safe and error-proof: Handles invalid configurations gracefully with default values and validations.

Installation

Install pixelfit via npm:

npm install pixelfit

Usage

Importing the Library

import Pixelfit from 'pixelfit';

Quick Start

1. Mobile Screen Adaptation

const pixelfit = new Pixelfit({ type: 'm', width: 750 });
pixelfit.pixelfit(); // Automatically adapts to the device size

2. Large Screen Adaptation

const pixelfit = new Pixelfit({ 
  type: 'l', 
  width: 1920, 
  height: 1080, 
  target: document.getElementById('app') 
});
pixelfit.pixelfit(); // Adapts the target element for large screens

3. Converting px to rem

// Convert 100px to rem based on a design width of 750px
const remValue = Pixelfit.px2rem(100, 750);
console.log(remValue); // Output: rem value

4. Converting rem to px

// Convert 1rem to px based on a design width of 750px
const pxValue = Pixelfit.rem2px(1, 750);
console.log(pxValue); // Output: px value

API Reference

Constructor

new Pixelfit(options)

| Parameter | Type | Default | Description | |--------------|----------|--------------------|------------------------------------------------| | type | string | 'm' | Adaptation type: 'm' for mobile, 'l' for large screens. | | width | number | 750 (mobile) / 1920 (large) | Design width for scaling. | | height | number | 1080 (large only) | Design height for large screens. | | target | HTMLElement | document.body | Target DOM element for large screen adaptation. |

Methods

.pixelfit()

Starts the adaptation process. Automatically resizes elements and applies scaling based on the selected type ('m' or 'l'). Automatically listens for resize events.

.largeScreenAdp()

Applies large screen adaptation. Automatically called when type is 'l'.

.mobileAdp()

Applies mobile screen adaptation. Automatically called when type is 'm'.

Pixelfit.px2rem(px, designWidth = 750)

Converts px to rem.

| Parameter | Type | Default | Description | |----------------|----------|---------|----------------------------------| | px | number | | The pixel value to convert. | | designWidth | number | 750 | The design width for conversion. |

Returns: number - The converted rem value.

Pixelfit.rem2px(rem, designWidth = 750)

Converts rem to px.

| Parameter | Type | Default | Description | |----------------|----------|---------|----------------------------------| | rem | number | | The rem value to convert. | | designWidth | number | 750 | The design width for conversion. |

Returns: number - The converted px value.

Example Project Structure

project/
├── src/
│   ├── index.js        # Your project entry point
├── dist/
│   ├── pixelfit.min.js # Minified bundle
├── package.json        # NPM package details
└── README.md           # Documentation

Development

Clone the repository and install dependencies:

git clone https://github.com/your-repo/pixelfit.git
cd pixelfit
npm install

Build the library:

npm run build

Run tests:

npm test

License

This project is licensed under the MIT License.