UMD Web Utilities Library
    Preparing search index...

    Function jssToCSS

    • Converts a JSS (JavaScript Style Sheets) object to a CSS string using PostCSS. Processes nested CSS structures and converts them into standard CSS syntax. This utility requires the postcss, postcss-nesting, and postcss-js dependencies.

      Parameters

      • styleObj: { styleObj: any }

        A JSS object with CSS properties and nested selectors

      Returns string

      A CSS string ready to be injected into a style element

      const jssObject = {
      '.container': {
      padding: '1rem',
      '& .child': {
      margin: '0.5rem'
      },
      '&:hover': {
      background: '#f0f0f0'
      }
      }
      };

      const css = jssToCSS({ styleObj: jssObject });
      // Returns:
      // .container {
      // padding: 1rem;
      // }
      // .container .child {
      // margin: 0.5rem;
      // }
      // .container:hover {
      // background: #f0f0f0;
      // }