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

@opensky/style

v0.1.0

Published

Utilities for styling in svelte

Downloads

4

Readme

@opensky/style

A collection of utility functions for styling in Svelte applications with Tailwind CSS support.

Installation

npm install @opensky/style

Usage

import { createClass, preserveClass, createVariants } from '@opensky/style'

API

createClass(...inputs)

Merges and processes CSS class names using clsx and tailwind-merge.

Parameters:

  • inputs - Class values to merge (strings, objects, arrays)

Returns:

  • String of merged and processed class names

Example:

// Basic usage - Tailwind conflicts resolved
createClass('text-lg', 'text-sm')
// Returns: "text-sm" (last conflicting Tailwind class wins)

// Conditional classes
createClass('flex', isActive && 'bg-blue-500', { 'opacity-50': isLoading })
// Returns: "flex bg-blue-500 opacity-50" (if both conditions are true)

// Mix regular and preserved classes
createClass('flex bg-red-500', 'bg-blue-500', preserveClass('custom-animation'))
// Returns: "flex bg-blue-500 custom-animation"

preserveClass(classes)

Marks classes to be preserved without Tailwind conflict resolution.

Parameters:

  • classes - Class values to preserve

Returns:

  • Preserved class object for use with createClass

Example:

// Preserve custom animation class
createClass('bg-red-500', preserveClass('custom-fade-in'))
// Returns: "bg-red-500 custom-fade-in"

// Preserve multiple classes conditionally
createClass('flex', preserveClass(['animate-spin', isLoading && 'opacity-50']))
// Returns: "flex animate-spin opacity-50" (if isLoading is true)

createVariants(options, props)

Creates a powerful variant system for components with support for base styles, variant groups, compound variants, and reset styles.

Parameters:

  • options - Configuration object containing:
    • base - Base classes always applied
    • reset - Classes applied when resetStyles is true
    • compound - Array of compound variant rules
    • [variantGroup] - Variant group definitions with options and optional _default
  • props - Props object containing variant selections and optional resetStyles

Returns:

  • Object containing:
    • classes - Final merged class string
    • [variantProp] - Selected variant values for each group

Example:

// Define variants
const buttonVariants = {
  base: 'px-4 py-2 font-medium rounded',
  reset: 'p-0 bg-transparent border-0',
  
  // Multi-option variants
  size: {
    sm: 'text-sm',
    md: 'text-base',
    lg: 'text-lg',
    _default: 'md'
  },
  variant: {
    primary: 'bg-blue-500 text-white',
    secondary: 'bg-gray-200 text-gray-800',
    danger: 'bg-red-500 text-white'
  },
  
  // Boolean toggle variants (string values)
  disabled: 'opacity-50 cursor-not-allowed',
  elevated: 'shadow-lg',
  
  // Compound variants
  compound: [
    {
      size: 'lg',
      variant: 'primary',
      classes: 'shadow-lg hover:shadow-xl'
    }
  ]
}

// Use in component
const result = createVariants(buttonVariants, { size: 'lg', variant: 'primary' })
// Returns: {
//   classes: 'px-4 py-2 font-medium rounded text-lg bg-blue-500 text-white shadow-lg hover:shadow-xl',
//   size: 'lg',
//   variant: 'primary'
// }

// With reset
const resetResult = createVariants(buttonVariants, { resetStyles: true })
// Returns: {
//   classes: 'p-0 bg-transparent border-0',
//   size: '_reset',
//   variant: '_reset'
// }

// With custom classes (not defined in options)
const customResult = createVariants(buttonVariants, { variant: 'custom-gradient' })
// Returns: {
//   classes: 'px-4 py-2 font-medium rounded text-base custom-gradient',
//   size: 'md', // default value
//   variant: 'custom-gradient'
// }

// Using boolean toggles
const toggleResult = createVariants(buttonVariants, { 
  size: 'sm', 
  variant: 'primary', 
  disabled: true, 
  elevated: true 
})
// Returns: {
//   classes: 'px-4 py-2 font-medium rounded text-sm bg-blue-500 text-white opacity-50 cursor-not-allowed shadow-lg',
//   size: 'sm',
//   variant: 'primary',
//   disabled: true,
//   elevated: true
// }

Dependencies

  • clsx - For conditional class handling
  • tailwind-merge - For Tailwind CSS class conflict resolution

License

MIT