Natty Precise Maverick

    TypeScript icon, indicating that this package has built-in type declarations

    0.1.4 • Public • Published

    JSS Default Theme

    npm version GitHub license Size Downloads

    Inspired by Material Design & React MUI theming.

    Independent part of jss-theme package.

    Demo & docs

    Demo and docs could be found here.

    Example in sandbox could be found here.


    Include necessary typescript typings.


    import { createDefaultJssTheme } from 'jss-theme-default';
    const theme = createDefaultJssTheme({ spacing: 12 });
    console.log(theme.spacing === 12);


    Default theme provides object for usage w/ JSS like stlyes approach.

    It also provides bunch of methods for updating this theme or creating new one with similar structure:

    Similar structure is here.

    • createDefaultJssTheme(themeConfig?, ThemeInstance?) => DefaultTheme Creates structure for DefaultTheme, with optional overrides. Second param is for existing ThemeInstance in order to bind mixins to it.
    • createTypography(typography?), createPalette(palette?), createBreakpoints(breakpoints?), createZIndex(zIndex?), createMixins(Theme) - aliases for creating DefaultTheme parts. Could be used for example for updating DefaultTheme theme. For each method it is possible to provide partial overrides, for all not overridden values will be used defaults.
    • IMPORTANT: createPalette(palette?): for main colors (primary, secondary, error, info, success, warning) it is OK to provide only main shade. Functions will automatically calculate light, dark and contrastText color. Still you can provide custom for all of them.
    • createColor(color, contrastText?, bw?) - For provided color creates color palette w/ lighten, darken, contrastText colors.
    • createGreyPalette(initial?) - Creates shades of grey for provided first shade.
    • createTypographyItem(fontFamily, fontWeight, fontSize, lineHeight) - Creates typography item object.
    • createShadows() - Creates shadows
    const shadows = createShadows(
        [1, 1, 1, 1, '#000', true],
        { x: 5, y: 5, blur: 5, spread: 5, color: '#000', inset: true },
    );// => inset 1px 1px 1px 1px #000, inset 5px 5px 5px 5px #000
    const shadows = createMaterialShadows(0, 2, 1, -1, 0, 1, 1, 0, 0, 1, 3, 0);
    • fade(color, opacity), darken(color, lvl?), lighten(color, lvl?), getContrastColor(color, bw?, black?, white?) Work w/ colors: transparency, getting dark / light shade, getting contrast text. If provided just 1 param to getContrastColor - it will invert color. If provide second boolean param -> it will get contrast (black/white color, where 3d and 4th params can override default colors for contrast black and white)

    Default theme signature

          primary"rgba(0, 0, 0, 0.87)",
          secondary"rgba(0, 0, 0, 0.54)",
          disabled"rgba(0, 0, 0, 0.38)",
          hint"rgba(0, 0, 0, 0.38)"
        divider"rgba(0, 0, 0, 0.12)",
          active"rgba(0, 0, 0, 0.54)",
          hover"rgba(0, 0, 0, 0.04)",
          selected"rgba(0, 0, 0, 0.08)",
          disabled"rgba(0, 0, 0, 0.26)",
          disabledBackground"rgba(0, 0, 0, 0.12)",
          focus"rgba(0, 0, 0, 0.12)",
        fontFamily"\"Roboto\"\"Helvetica\"\"Arial\", sans-serif",
          fontFamily"\"Roboto\"\"Helvetica\"\"Arial\", sans-serif",
          fontFamily"\"Roboto\"\"Helvetica\"\"Arial\", sans-serif",
          fontFamily"\"Roboto\"\"Helvetica\"\"Arial\", sans-serif",
          fontFamily"\"Roboto\"\"Helvetica\"\"Arial\", sans-serif",
          fontFamily"\"Roboto\"\"Helvetica\"\"Arial\", sans-serif",
          fontFamily"\"Roboto\"\"Helvetica\"\"Arial\", sans-serif",
          fontFamily"\"Roboto\"\"Helvetica\"\"Arial\", sans-serif",
          fontFamily"\"Roboto\"\"Helvetica\"\"Arial\", sans-serif",
          fontFamily"\"Roboto\"\"Helvetica\"\"Arial\", sans-serif",
          fontFamily"\"Roboto\"\"Helvetica\"\"Arial\", sans-serif",
          fontFamily"\"Roboto\"\"Helvetica\"\"Arial\", sans-serif",
          fontFamily"\"Roboto\"\"Helvetica\"\"Arial\", sans-serif",
          fontFamily"\"Roboto\"\"Helvetica\"\"Arial\", sans-serif",
          l: (...breakpoints: Array<string | number | [string, number, number?]>) => string,
          rl: (...breakpoints: Array<string | number | [string, number, number?]>) => string,
          r: (...breakpoints: Array<string | number | [string, number, number?]>) => string,
          rr: (...breakpoints: Array<string | number | [string, number, number?]>) => string,
        spacing: (...units: Array<number | string>) => string,
        border: (units?: number, color?: string) => string,
        font: (prop: JssThemeTypographyItems) => string,
        transition: (transition: string, duration?: number | string, delay?: number | string, prop?: string) => string,
        fade: (color: string, opacity?: string | number) => string,
        darken: (customColor: string, coef?: number) => string,
        lighten: (customColor: string, coef?: number) => string,
        getContrastColor: (color: string, bw?: boolean, black?: string, white?: string) => string,
        boxShadow: (...shadows: Array<JssThemeShadowTuple | JssThemeShadowObject>) => string,
        pxToRem: (size: number) => string,
        "0px 2px 1px -1px rgba(0,0,0,0.2),0px 1px 1px 0px rgba(0,0,0,0.14),0px 1px 3px 0px rgba(0,0,0,0.12)",
        "0px 3px 1px -2px rgba(0,0,0,0.2),0px 2px 2px 0px rgba(0,0,0,0.14),0px 1px 5px 0px rgba(0,0,0,0.12)",
        "0px 3px 3px -2px rgba(0,0,0,0.2),0px 3px 4px 0px rgba(0,0,0,0.14),0px 1px 8px 0px rgba(0,0,0,0.12)",
        "0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12)",
        "0px 3px 5px -1px rgba(0,0,0,0.2),0px 5px 8px 0px rgba(0,0,0,0.14),0px 1px 14px 0px rgba(0,0,0,0.12)",
        "0px 3px 5px -1px rgba(0,0,0,0.2),0px 6px 10px 0px rgba(0,0,0,0.14),0px 1px 18px 0px rgba(0,0,0,0.12)",
        "0px 4px 5px -2px rgba(0,0,0,0.2),0px 7px 10px 1px rgba(0,0,0,0.14),0px 2px 16px 1px rgba(0,0,0,0.12)",
        "0px 5px 5px -3px rgba(0,0,0,0.2),0px 8px 10px 1px rgba(0,0,0,0.14),0px 3px 14px 2px rgba(0,0,0,0.12)",
        "0px 5px 6px -3px rgba(0,0,0,0.2),0px 9px 12px 1px rgba(0,0,0,0.14),0px 3px 16px 2px rgba(0,0,0,0.12)",
        "0px 6px 6px -3px rgba(0,0,0,0.2),0px 10px 14px 1px rgba(0,0,0,0.14),0px 4px 18px 3px rgba(0,0,0,0.12)",
        "0px 6px 7px -4px rgba(0,0,0,0.2),0px 11px 15px 1px rgba(0,0,0,0.14),0px 4px 20px 3px rgba(0,0,0,0.12)",
        "0px 7px 8px -4px rgba(0,0,0,0.2),0px 12px 17px 2px rgba(0,0,0,0.14),0px 5px 22px 4px rgba(0,0,0,0.12)",
        "0px 7px 8px -4px rgba(0,0,0,0.2),0px 13px 19px 2px rgba(0,0,0,0.14),0px 5px 24px 4px rgba(0,0,0,0.12)",
        "0px 7px 9px -4px rgba(0,0,0,0.2),0px 14px 21px 2px rgba(0,0,0,0.14),0px 5px 26px 4px rgba(0,0,0,0.12)",
        "0px 8px 9px -5px rgba(0,0,0,0.2),0px 15px 22px 2px rgba(0,0,0,0.14),0px 6px 28px 5px rgba(0,0,0,0.12)",
        "0px 8px 10px -5px rgba(0,0,0,0.2),0px 16px 24px 2px rgba(0,0,0,0.14),0px 6px 30px 5px rgba(0,0,0,0.12)",
        "0px 8px 11px -5px rgba(0,0,0,0.2),0px 17px 26px 2px rgba(0,0,0,0.14),0px 6px 32px 5px rgba(0,0,0,0.12)",
        "0px 9px 11px -5px rgba(0,0,0,0.2),0px 18px 28px 2px rgba(0,0,0,0.14),0px 7px 34px 6px rgba(0,0,0,0.12)",
        "0px 9px 12px -6px rgba(0,0,0,0.2),0px 19px 29px 2px rgba(0,0,0,0.14),0px 7px 36px 6px rgba(0,0,0,0.12)",
        "0px 10px 13px -6px rgba(0,0,0,0.2),0px 20px 31px 3px rgba(0,0,0,0.14),0px 8px 38px 7px rgba(0,0,0,0.12)",
        "0px 10px 13px -6px rgba(0,0,0,0.2),0px 21px 33px 3px rgba(0,0,0,0.14),0px 8px 40px 7px rgba(0,0,0,0.12)",
        "0px 10px 14px -6px rgba(0,0,0,0.2),0px 22px 35px 3px rgba(0,0,0,0.14),0px 8px 42px 7px rgba(0,0,0,0.12)",
        "0px 11px 14px -7px rgba(0,0,0,0.2),0px 23px 36px 3px rgba(0,0,0,0.14),0px 9px 44px 8px rgba(0,0,0,0.12)",
        "0px 11px 15px -7px rgba(0,0,0,0.2),0px 24px 38px 3px rgba(0,0,0,0.14),0px 9px 46px 8px rgba(0,0,0,0.12)"
          easeInOut"cubic-bezier(0.4, 0, 0.2, 1)",
          easeOut"cubic-bezier(0.0, 0, 0.2, 1)",
          easeIn"cubic-bezier(0.4, 0, 1, 1)",
          sharp"cubic-bezier(0.4, 0, 0.6, 1)"


    npm i jss-theme-default

    DownloadsWeekly Downloads






    Unpacked Size

    255 kB

    Total Files


    Last publish


    • mopc