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

css-in-js-utilities

v1.0.0-beta.2

Published

A modern collection of helper functions for CSS-in-JS libraries

Readme

🎨 CSS-in-JS Utilities: Your Styling Superpower!

A modern, comprehensive collection of helper functions and utilities for CSS-in-JS libraries. This package provides a set of TypeScript utilities to speed up common styling tasks and improve consistency in your projects. Say goodbye to repetitive styling tasks and hello to consistent, efficient, and downright-friendly styling!

✨ Features

  • Responsive design utilities
  • Layout helpers (Flexbox and Grid)
  • Typography helpers
  • Color utilities
  • Effects (shadows and transitions)
  • Animation utilities

🚀 Getting Started

Install the package using npm:

npm install css-in-js-utilities

or

yarn add css-in-js-utilities

Usage Guide

CSS-in-JS Utilities offers a wide range of powerful functions to enhance your styling workflow. Let's explore each category with practical examples:

Responsive design utilities

Create adaptive layouts with ease:

import { responsive } from 'css-in-js-utilities';

const responsiveStyles = responsive({
    display: { base: 'block', md: 'flex' },
    fontSize: { base: '14px', md: '16px', xl: '18px' },
});
// Result:
// {
//   display: 'block',
//   fontSize: '14px',
//   '@media (min-width: 768px)': {
//     display: 'flex',
//     fontSize: '16px'
//   },
//   '@media (min-width: 1280px)': {
//     fontSize: '18px'
//   }
// }

Flex Layout

Create flexible layouts with intuitive controls:

import { flexContainer, flexItem } from 'css-in-js-utilities';

const container = flexContainer('column', 'space-between', 'center');
// Result:
// {
//   display: 'flex',
//   flexDirection: 'column',
//   justifyContent: 'space-between',
//   alignItems: 'center'
// }

const item = flexItem(2, 1, '100px');
// Result:
// {
//   flexGrow: 2,
//   flexShrink: 1,
//   flexBasis: '100px'
// }

Grid Layout

Build complex grid systems effortlessly:

import { gridContainer, gridItem } from 'css-in-js-utilities';

const container = gridContainer(3, 2, '20px', 'center', 'end', 'space-between', 'space-around');
// Result:
// {
//   display: 'grid',
//   gridTemplateColumns: 'repeat(3, 1fr)',
//   gridTemplateRows: 'repeat(2, 1fr)',
//   gap: '20px',
//   justifyItems: 'center',
//   alignItems: 'end',
//   justifyContent: 'space-between',
//   alignContent: 'space-around'
// }

const item = gridItem(1, 3, 2, 4, 'start', 'center');
// Result:
// {
//   gridColumnStart: 1,
//   gridColumnEnd: 3,
//   gridRowStart: 2,
//   gridRowEnd: 4,
//   justifySelf: 'start',
//   alignSelf: 'center'
// }

Typography

Fine-tune your text styles:

import { fontSize, fontWeight, lineHeight, letterSpacing, textAlign, createTypography } from 'css-in-js-utilities';

const responsiveFontSize = fontSize({ base: '16px', md: '18px', lg: '20px' });
// Result: { fontSize: { base: '16px', md: '18px', lg: '20px' } }

const boldWeight = fontWeight('bold');
// Result: { fontWeight: 'bold' }

const customLineHeight = lineHeight(1.5);
// Result: { lineHeight: 1.5 }

const wideLetterSpacing = letterSpacing('0.05em');
// Result: { letterSpacing: '0.05em' }

const centerAlign = textAlign('center');
// Result: { textAlign: 'center' }

const headingTypography = createTypography('heading', '24px', 'bold', 'center');
// Result:
// {
//   fontSize: '24px',
//   fontWeight: 'bold',
//   textAlign: 'center',
//   lineHeight: 1.2,
//   letterSpacing: '-0.02em'
// }

// Using createTypography with breakpoints
const responsiveHeadingTypography = createTypography('heading', { base: '24px', md: '32px' }, 'bold', 'center');
// Result:
// {
//   fontSize: '24px',
//   fontWeight: 'bold',
//   textAlign: 'center',
//   lineHeight: 1.2,
//   letterSpacing: '-0.02em',
//   '@media (min-width: 768px)': { fontSize: '32px' }
// }

Color Utilities

Effortlessly manage and manipulate colors:

import { toRgba, lighten, darken, complementary, analogous } from 'css-in-js-utilities';

const rgbaColor = toRgba('#FF5733', 0.8);
// Result: 'rgba(255, 87, 51, 0.8)'

const lightenedColor = lighten('#3366CC', 20);
// Result: '#6699FF'

const darkenedColor = darken('#3366CC', 20);
// Result: '#003399'

const complementaryColor = complementary('#3366CC');
// Result: '#CC9933'

const analogousColor = analogous('#3366CC', 30);
// Result: '#3333CC'

Shadow Effects

Add depth to your elements:

import { boxShadow, textShadow } from 'css-in-js-utilities';

const boxShadowStyle = boxShadow('lg', 'rgba(0, 0, 255, 0.2)', true);
// Result: { boxShadow: 'inset 0px 4px 8px 0px rgba(0, 0, 255, 0.2)' }

const textShadowStyle = textShadow('xl', 'rgba(255, 0, 0, 0.3)');
// Result: { textShadow: '0px 8px 16px rgba(255, 0, 0, 0.3)' }

Transition Utilities

Create smooth state changes:

import { transition, multipleTransitions } from 'css-in-js-utilities';

const singleTransition = transition('opacity', 300, 'ease-in-out', 100);
// Result: { transition: 'opacity 300ms ease-in-out 100ms' }

const multiTransition = multipleTransitions(
    transition('opacity', 300),
    transition('transform', 500, 'ease-out', 100)
);
// Result: { transition: 'opacity 300ms ease 0ms, transform 500ms ease-out 100ms' }

Animation Utilities

Bring your UI to life with our animation helpers:

import { keyframe, animation, multipleAnimations } from 'css-in-js-utilities';

// Define keyframes
const fadeIn = keyframe('fadeIn', {
  from: { opacity: 0 },
  to: { opacity: 1 }
});
// Result: '@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }'

// Create a single animation
const fadeInAnimation = animation('fadeIn', '1s', 'ease-in-out');
// Result: 'fadeIn 1s ease-in-out 0s 1 normal none running'

// Combine multiple animations
const complexAnimation = multipleAnimations(
  animation('fadeIn', '1s'),
  animation('slideIn', '0.5s', 'ease-out', '0.2s')
);
// Result: { animation: 'fadeIn 1s ease 0s 1 normal none running, slideIn 0.5s ease-out 0.2s 1 normal none running' }

🤝 Contributing

We're always looking for fellow style enthusiasts to join our ranks! Whether you're reporting bugs, suggesting features, or contributing code, your ideas can help shape the future of the package. If you'd like to contribute, please follow these contribution guidelines:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/SpecificFeature)
  3. Commit your changes (git commit -m 'Add some SpecificFeature')
  4. Push to the branch (git push origin feature/SpecificFeature)
  5. Open a Pull Request

For more detailed information on contributing, please see our CONTRIBUTE.md file.

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

Copyright (c) 2024 Ameen Alade