How to use the styled-jsx/server function in styled-jsx

To help you get started, we’ve selected a few styled-jsx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mui-org / material-ui-pickers / docs / pages / _document.tsx View on Github external
let css: string;
    // It might be undefined, e.g. after an error.
    if (pageContext) {
      css = pageContext.sheetsRegistry.toString();
    }

    return {
      ...page,
      theme,
      pageContext,
      // Styles fragment is rendered after the app and page rendering finish.
      styles: (
github thundermiracle / next-mui-helper / src / nextjs / extendsWithMui.js View on Github external
const sheets = new ServerStyleSheets();
      const originalRenderPage = ctx.renderPage;
      ctx.renderPage = () =>
        originalRenderPage({
          // wrap Jss context
          enhanceApp: App => props => sheets.collect(),
        });

      // get props after override the renderPage to get jss props
      const superProps = await super.getInitialProps(ctx);

      // push to head instead of override styles
      superProps.head.push(
        
          {sheets.getStyleElement()}
          {flush() || null}
        ,
      );

      return {
        ...superProps,
      };
    }
github drex44 / good-food-guide / www / pages / _document.js View on Github external
});

  return {
    ...page,
    pageContext,
    // Styles fragment is rendered after the app and page rendering finish.
    styles: (
github mui-org / material-ui / examples / nextjs-with-typescript / pages / _document.tsx View on Github external
const originalRenderPage = ctx.renderPage;

  ctx.renderPage = () =>
    originalRenderPage({
      enhanceApp: App => props => sheets.collect(),
    });

  const initialProps = await Document.getInitialProps(ctx);

  return {
    ...initialProps,
    // Styles fragment is rendered after the app and page rendering finish.
    styles: (
      
        {sheets.getStyleElement()}
        {flush() || null}
      
    ),
  };
};
github geovanisouza92 / serverless-next / pages / _document.js View on Github external
static getInitialProps ({ renderPage }) {
    const {html, head, errorHtml, chunks} = renderPage()
    const styles = flush()
    return {html, head, errorHtml, chunks, styles}
  }
github liors / tvdapp / pages / _document.js View on Github external
static getInitialProps ({ renderPage }) {
    const {html, head, errorHtml, chunks} = renderPage()
    const styles = flush()
    return { html, head, errorHtml, chunks, styles }
  }
github Maxvien / next-shopify-storefront / hocs / withMuiDoc.tsx View on Github external
const originalRenderPage = ctx.renderPage;

      ctx.renderPage = () => {
        return originalRenderPage({
          enhanceApp: App => props => sheets.collect(),
        });
      };

      const initialProps = await Document.getInitialProps(ctx);

      return {
        ...initialProps,
        styles: (
          <>
            {sheets.getStyleElement()}
            {flush() || null}
          
        ),
      };
    }
github JMPerez / c / pages / _document.js View on Github external
static async getInitialProps(context) {
    const props = await super.getInitialProps(context);
    const { req: { locale, localeDataScript } } = context;
    const { html, head, errorHtml, chunks } = context.renderPage();
    const styles = flush();
    return { html, head, errorHtml, chunks, styles, locale, localeDataScript };
  }
github slorber / react-reboot / src / pages / _document.js View on Github external
static async getInitialProps({ renderPage }) {
    const page = renderPage();
    const styles = renderStatic(() => page.html);
    return {
      ...page,
      ...styles,
      jsxStyleCss: flush(),
    };
  }
github nteract / commuter / pages / _document.js View on Github external
static getInitialProps(context: Object) {
    const renderPage = context.renderPage;
    const { html, head, errorHtml, chunks } = renderPage();
    const styles = flush();
    return { html, head, errorHtml, chunks, styles };
  }

styled-jsx

Full CSS support for JSX without compromises

MIT
Latest version published 7 months ago

Package Health Score

86 / 100
Full package analysis