Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Google Material Design Elevations
// Google Material Design 1-24dp elevations (shadows)
const umbraOpacity = '0.2';
const penumbraOpacity = '0.14';
const ambientOpacity = '0.12';
// map index are [0-24]
const elevationUmbraMap = [
'0px 0px 0px 0px',
'0px 2px 1px -1px',
'0px 3px 1px -2px',
'0px 3px 3px -2px',
'0px 2px 4px -1px',
'0px 3px 5px -1px',
'0px 3px 5px -1px',
'0px 4px 5px -2px',
'0px 5px 5px -3px',
'0px 5px 6px -3px',
'0px 6px 6px -3px',
'0px 6px 7px -4px',
'0px 7px 8px -4px',
'0px 7px 8px -4px',
'0px 7px 9px -4px',
'0px 8px 9px -5px',
'0px 8px 10px -5px',
'0px 8px 11px -5px',
'0px 9px 11px -5px',
'0px 9px 12px -6px',
'0px 10px 13px -6px',
'0px 10px 13px -6px',
'0px 10px 14px -6px',
'0px 11px 14px -7px',
'0px 11px 15px -7px',
const elevationPenumbraMap = [
'0px 0px 0px 0px',
'0px 1px 1px 0px',
'0px 2px 2px 0px',
'0px 3px 4px 0px',
'0px 4px 5px 0px',
'0px 5px 8px 0px',
'0px 6px 10px 0px',
'0px 7px 10px 1px',
'0px 8px 10px 1px',
'0px 9px 12px 1px',
'0px 10px 14px 1px',
'0px 11px 15px 1px',
'0px 12px 17px 2px',
'0px 13px 19px 2px',
'0px 14px 21px 2px',
'0px 15px 22px 2px',
'0px 16px 24px 2px',
'0px 17px 26px 2px',
'0px 18px 28px 2px',
'0px 19px 29px 2px',
'0px 20px 31px 3px',
'0px 21px 33px 3px',
'0px 22px 35px 3px',
'0px 23px 36px 3px',
'0px 24px 38px 3px',
const elevationAmbientMap = [
'0px 0px 0px 0px',
'0px 1px 3px 0px',
'0px 1px 5px 0px',
'0px 1px 8px 0px',
'0px 1px 10px 0px',
'0px 1px 14px 0px',
'0px 1px 18px 0px',
'0px 2px 16px 1px',
'0px 3px 14px 2px',
'0px 3px 16px 2px',
'0px 4px 18px 3px',
'0px 4px 20px 3px',
'0px 5px 22px 4px',
'0px 5px 24px 4px',
'0px 5px 26px 4px',
'0px 6px 28px 5px',
'0px 6px 30px 5px',
'0px 6px 32px 5px',
'0px 7px 34px 6px',
'0px 7px 36px 6px',
'0px 8px 38px 7px',
'0px 8px 40px 7px',
'0px 8px 42px 7px',
'0px 9px 44px 8px',
'0px 9px 46px 8px',
const elevation = (index) => `${elevationUmbraMap[index]} rgba(0, 0, 0, ${umbraOpacity}), ${elevationPenumbraMap[index]} rgba(0, 0, 0, ${penumbraOpacity}), ${elevationAmbientMap[index]} rgba(0, 0, 0, ${ambientOpacity}) `;
export const s0 = elevation(0);
export const s1 = elevation(1);
export const s2 = elevation(2);
export const s3 = elevation(3);
export const s4 = elevation(4);
export const s5 = elevation(5);
export const s6 = elevation(6);
export const s7 = elevation(7);
export const s8 = elevation(8);
export const s9 = elevation(9);
export const s10 = elevation(10);
export const s11 = elevation(11);
export const s12 = elevation(12);
export const s13 = elevation(13);
export const s14 = elevation(14);
export const s15 = elevation(15);
export const s16 = elevation(16);
export const s17 = elevation(17);
export const s18 = elevation(18);
export const s19 = elevation(19);
export const s20 = elevation(20);
export const s21 = elevation(21);
export const s22 = elevation(22);
export const s23 = elevation(23);
export const s24 = elevation(24);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment