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

@stylix/core

v6.4.3

Published

React, with style. Add styles to your React apps with props: the easy, natural, and low learning curve approach.

Readme

Stylix

Props-based CSS-in-JS for React

import $ from '@stylix/core';

<$.div color="teal" font-size={24} padding={16}>
  Hello, Stylix!
</$.div>

Stylix lets you write CSS as JSX props. If you know CSS and React, you already know Stylix.


Features

  • Zero learning curve — CSS properties become component props
  • Full CSS support — pseudo-classes, media queries, keyframes, container queries, cascade layers
  • Type-safe — TypeScript autocomplete and validation for all CSS properties
  • Responsive design — define breakpoints once, use them everywhere
  • Lightweight — no build step required, works with any React setup

Installation

npm install @stylix/core

Quick Start

Basic Styling

Use any HTML element via the $ namespace with CSS properties as props:

import $ from '@stylix/core';

<$.div
  display="flex"
  gap={16}
  padding={24}
  background="#f5f5f5"
  border-radius={8}
>
  <$.span color="blue" font-weight="bold">Styled text</$.span>
</$.div>

Numeric values automatically get px units (except for unitless properties like flex, opacity, z-index).

Complex Styles with $css

For pseudo-classes, selectors, and media queries, use the $css prop:

<$.button
  padding="12px 24px"
  background="blue"
  color="white"
  border="none"
  $css={{
    '&:hover': { background: 'darkblue' },
    '&:active': { transform: 'scale(0.98)' },
    '@media (max-width: 600px)': { padding: '8px 16px' }
  }}
>
  Click me
</$.button>

Responsive Props

Define breakpoints in a provider, then use them in any prop:

import $, { StylixProvider } from '@stylix/core';

// Define once at app root
<StylixProvider
  media={{
    mobile: styles => ({ '@media (max-width: 768px)': styles }),
    tablet: styles => ({ '@media (max-width: 1024px)': styles }),
  }}
>
  <App />
</StylixProvider>

// Use anywhere
<$.div
  font-size={{ default: 18, tablet: 16, mobile: 14 }}
  padding={{ default: 32, mobile: 16 }}
/>

Creating Components

Spread style props to create reusable, customizable components:

import $, { StylixProps } from '@stylix/core';

function Button({ children, ...styles }: StylixProps & { children: React.ReactNode }) {
  return (
    <$.button
      padding="10px 20px"
      border="none"
      border-radius={4}
      cursor="pointer"
      {...styles}
    >
      {children}
    </$.button>
  );
}

// Parent can override any style
<Button background="green" color="white">Save</Button>

Documentation

| Document | Description | |----------|-------------| | Cheatsheet | Quick reference for common patterns | | Philosophy | Why Stylix exists and when to use it | | Patterns | Detailed examples and best practices | | Performance | Optimization guidelines |


How It Works

Stylix generates unique class names based on your styles and injects CSS at runtime:

<$.div color="red" padding={16} />

Renders as:

<div class="stylix-a1b2c3">...</div>

With CSS:

.stylix-a1b2c3 {
  color: red;
  padding: 16px;
}

Identical styles share class names automatically—100 elements with the same styles create only one CSS rule.


When to Use Stylix

Good for:

  • Small-to-medium applications
  • Rapid prototyping
  • Teams that prefer colocated styles
  • Augmenting existing styling approaches

Consider alternatives for:

  • Large component libraries intended for external use
  • Applications where bundle size is critical
  • High-frequency animations (use CSS transitions or the native style prop)

See Philosophy for more context on these tradeoffs.


Browser Support

Stylix uses native CSS nesting for complex styles. Check Can I use CSS Nesting for current browser support (90%+ as of 2024).

For basic prop-based styles without nesting, all modern browsers are supported.


API Overview

Exports

import $, {
  StylixProvider,    // Context provider for configuration
  StylixProps,       // TypeScript type for style props
  useKeyframes,      // Create keyframe animations
  useGlobalStyles,   // Define global styles
  cx,                // Class name utility
} from '@stylix/core';

StylixProvider Props

<StylixProvider
  media={{ /* breakpoint definitions */ }}
  plugins={[ /* custom plugins */ ]}
  ssr={true}  // Enable server-side rendering mode
>

License

MIT


Links