Skip to content

Add pigment-css to nextjs using manual installation docs #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kdichev
Copy link
Owner

@kdichev kdichev commented Sep 21, 2024

these are the steps I did using the manual installation docs from mui documentation:

Step 1:

npm install @pigment-css/react
npm install --save-dev @pigment-css/nextjs-plugin

Step 2:

// next.config.js
import { withPigment } from '@pigment-css/nextjs-plugin';

export default withPigment({ nextConfig });

Step 3:

// src/app/layout.tsx
import '@pigment-css/react/styles.css';

Step 4:

import { withPigment } from "@pigment-css/nextjs-plugin";

/** @type {import('next').NextConfig} */
const nextConfig = {};

export default withPigment(nextConfig, {
  theme: {
    colors: {
      primary: "tomato",
      secondary: "cyan",
    },
    spacing: {
      unit: 8,
    },
    typography: {
      fontFamily: "sans-serif",
    },
  },
});

@kdichev
Copy link
Owner Author

kdichev commented Sep 21, 2024

Key takeaways from initial 4 steps:

  1. when importing from @mui/material for example a Button the theme is not applied
  2. when creating Header with styled the theme is applied
import { styled } from "@pigment-css/react";

const Heading = styled("h1")(({ theme }) => ({
  color: theme.colors.primary,
  fontSize: theme.spacing.unit * 4,
  fontFamily: theme.typography.fontFamily,
}));
  1. sx prop does not work at all on imported components from @mui/material neither theme aware properties, nor css style properties
  2. sx prop theme aware properties does not work on component created with styled, nor it works on html elements
 <Heading
    sx={{
      marginTop: 1, // outputs margin-top: 1px
      mt: 1, // out puts mt: 1 and hence is not working
    }}
  >
    Heading
</Heading>
  1. There is an misstake in the documentation second step
// next.config.js
import { withPigment } from '@pigment-css/nextjs-plugin';

export default withPigment({ nextConfig }); 

// should be 
export default withPigment(nextConfig); 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant