You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@griffel/react

Package Overview
Dependencies
Maintainers
6
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@griffel/react

React implementation of Atomic CSS-in-JS

1.5.30
latest
Source
npmnpm
Version published
Maintainers
6
Created

What is @griffel/react?

@griffel/react is a CSS-in-JS library designed to provide a performant and flexible way to style React components. It focuses on runtime performance and developer experience, offering features like atomic CSS, theming, and server-side rendering support.

What are @griffel/react's main functionalities?

Atomic CSS

Griffel generates atomic CSS classes for each style rule, ensuring minimal CSS output and better performance.

const useStyles = makeStyles({
  root: { color: 'red' },
  button: { backgroundColor: 'blue' }
});

function MyComponent() {
  const classes = useStyles();
  return (
    <div className={classes.root}>
      <button className={classes.button}>Click me</button>
    </div>
  );
}

Theming

Griffel supports theming, allowing you to define and use theme variables throughout your application.

const theme = {
  color: 'blue',
  background: 'lightgray'
};

const useStyles = makeStyles({
  root: theme => ({
    color: theme.color,
    backgroundColor: theme.background
  })
});

function MyComponent() {
  const classes = useStyles(theme);
  return <div className={classes.root}>Themed Component</div>;
}

Server-Side Rendering

Griffel supports server-side rendering, ensuring that styles are correctly rendered on the server and sent to the client.

import { renderToString } from 'react-dom/server';
import { GriffelProvider, makeStyles } from '@griffel/react';

const useStyles = makeStyles({
  root: { color: 'red' }
});

function MyComponent() {
  const classes = useStyles();
  return <div className={classes.root}>Hello SSR</div>;
}

const html = renderToString(
  <GriffelProvider>
    <MyComponent />
  </GriffelProvider>
);

Other packages similar to @griffel/react

FAQs

Package last updated on 22 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts