Joe Buza
function truncate(width) { return ` width: ${width}; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; `; } const Box = styled.div` ${ truncate('250px') } background: papayawhip; `;
@mixin handheld { @media (max-width: 420px) { @content; } } .box { font-size: 16px; @include handheld { font-size: 14px; } }
const media = { handheld: (...args) => css` @media (max-width: 420px) { ${ css(...args) } } ` } // Make the text smaller on handheld devices const Box = styled.div` font-size: 16px; ${ media.handheld` font-size: 14px; ` } `;
By Joe Buza
The best way to style React components!