Utilities for rotating elements with transform.

React propsCSS Properties
rotate={angle}--x-rotate: {angle};


Rotate an element by first enabling transforms with the transform utility, then specifying the rotation angle using the rotate={angle} utility.

<> <template preview> <x.div display="flex" flexDirection={{ xs: 'column', md: 'row' }} justifyContent="space-around" spaceY={{ xs: 0, md: 12 }} spaceY={{ xs: 12, md: 0 }} my={10} > {[0, 45, '0.5turn', 120].map((angle) => ( <x.div key={angle} w={16} h={16} bg="red-300" borderRadius="md"> <x.img h={16} w={16} transform rotate={angle} borderRadius="md" src="" /> </x.div> ))} </x.div> </template> <x.img transform rotate={0} /> <x.img transform rotate={45} /> <x.img transform rotate="0.5turn" /> <x.img transform rotate={120} /> </>


To control the rotation of an element at a specific breakpoint, use responsive object notation. For example, adding the property rotate={{ md: 90 }} to an element would apply the rotate={90} utility at medium screen sizes and above.

<x.div transform rotate={{ md: 90 }} />

For more information about xstyled's responsive design features, check out Responsive Design documentation.

Edit this page on GitHub