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 🙏

© 2025 – Pkg Stats / Ryan Hefner

dripsy-variants

v1.0.3

Published

Utility to create style variants and compound variants for Dripsy.

Readme

dripsy-variants

Variant utility for Dripsy – A lightweight helper to build style variants and compound variants using sx props.

Inspired by Tailwind Variants and styled-system patterns.

✨ Features

  • ✅ Define base styles
  • ✅ Support for multiple variants
  • ✅ Support for compoundVariants
  • defaultVariants handling
  • ✅ Type-safe with full TypeScript support

📦 Installation

npm install dripsy-variants
# or
yarn add dripsy-variants

Make sure you also have dripsy installed.

🚀 Usage

import { createDripsyVariant } from "dripsy-variants";

const getButtonStyles = createDripsyVariant({
  base: {
    flexDirection: "row",
    alignItems: "center",
    gap: 10,
  },
  variants: {
    variant: {
      primary: { backgroundColor: "#0F0F0F" },
      secondary: { backgroundColor: "#E8E8E8" },
      link: { backgroundColor: "transparent" },
    },
    size: {
      md: { py: "$1_5", px: "$2", borderRadius: 16 },
      sm: { py: "$1", px: "$2", borderRadius: 12 },
    },
    disabled: {
      true: {},
      false: {},
    },
    pressed: {
      true: {},
      false: {},
    },
  },
  compoundVariants: [
    {
      pressed: ["true"],
      variant: ["primary"],
      sx: { backgroundColor: "#454545" },
    },
    {
      pressed: ["true"],
      variant: ["secondary"],
      sx: { backgroundColor: "#D3D3D3" },
    },
    {
      disabled: ["true"],
      variant: ["primary"],
      sx: { backgroundColor: "#F3F3F3" },
    },
    {
      disabled: ["true"],
      variant: ["secondary"],
      sx: { backgroundColor: "#F3F3F3" },
    },
  ],
  defaultVariants: {
    variant: "primary",
    size: "md",
  },
});

const getTextStyles = createSxVariant({
  base: {
    textAlign: "center",
    flex: 1,
  },
  variants: {
    variant: {
      primary: { color: "$white" },
      secondary: { color: "#2A2E2F" },
      link: { color: "#2A2E2F" },
    },
    size: {
      md: { variant: "text.$buttonMd" },
      sm: { variant: "text.$buttonSm" },
    },
    disabled: {
      true: {},
      false: {},
    },
    pressed: {
      true: {},
      false: {},
    },
  },
  compoundVariants: [
    {
      disabled: ["true"],
      variant: ["primary"],
      sx: { color: "#A8A8A8" },
    },
    {
      disabled: ["true"],
      variant: ["secondary"],
      sx: { color: "#D3D3D3" },
    },
    {
      disabled: ["true"],
      variant: ["link"],
      sx: { color: "#A8A8A8" },
    },
  ],
  defaultVariants: {
    variant: "primary",
    size: "md",
  },
});

// Usage
export const Button = ({
  title,
  onPress = () => {},
  icon,
  isLoading = false,
  disabled = false,
  sx = {},
  variant = "primary",
  size = "md",
}: ButtonProps) => {
  const sxConverter = useSx();
  const { theme } = useDripsyTheme();

  return (
    <Pressable
      disabled={isLoading || disabled}
      onPress={onPress}
      style={({ pressed }) =>
        sxConverter({
          ...getButtonStyles({
            variant,
            size,
            pressed: pressed ? "true" : "false",
            disabled: disabled ? "true" : "false",
          }),
          ...sx,
        })
      }
    >
      {({ pressed }) => {
        const textStyles = getTextStyles({
          variant,
          size,
          disabled: disabled ? "true" : "false",
          pressed: pressed ? "true" : "false",
        });

        const colorToken = textStyles.color as keyof typeof theme.colors;
        const resolvedColor = theme.colors?.[colorToken] ?? colorToken;

        const renderedIcon = enhanceIconElement(icon, {
          color: resolvedColor,
          size: 16,
        });

        return (
          <>
            <View sx={{ width: 20 }}>{isLoading && <Spinner />}</View>
            <Text sx={textStyles}>{title}</Text>
            <View sx={{ width: 20 }}>{icon && renderedIcon}</View>
          </>
        );
      }}
    </Pressable>
  );
};

🧠 API Reference

createDripsyVariant(config)

config.base?: SxProp

Base styles applied to all variants.

config.variants?: Record<string, Record<string, SxProp>>

Object containing named variants (like variant, size, etc.).

config.defaultVariants?: { [K in keyof Variants]?: keyof Variants[K] }

Default values used when no variant prop is passed.

config.compoundVariants?: CompoundVariant[]

List of compound variant conditions to apply extra styles based on a combination of variant values.

Each CompoundVariant is:

{ sx: SxProp; [key: string]: string[]; // matches variant keys and values }

🪪 License

MIT License © 2025 Axel Valles