Below is my xstyled.cutom.js looks like.
import { createCss, system, compose, style } from '@xstyled/styled-components';
export const clearfix = style({
prop: 'clearfix',
css: () => ({
'&::after': {
display: 'block',
content: '',
clear: 'both',
},
}),
});
export const foo = style({
prop: ['foo'],
css: ['paddingTop', 'paddingBottom'],
})
export const { css, styled, x, createGlobalStyle } = createCss(compose(system, clearfix, foo));
💬 Questions and Help
Hi,
I'm using xstyled for my project and keen on using some utils like
centerAlign,clearFixetc to be used as props on x elements as<x.div centerAlign clearfix ....I'm using it in a TS project and following this guide https://xstyled.dev/docs/adding-new-utilities/
and https://xstyled.dev/docs/typescript/
It says to create the xstyled.config.js but what to do with it I'm not sure. I created it in the project root but it doesn't seem to work. Also, TS is not able to identify the custom prop of
centerAlignadded. The TS guide only talks about custom theme types.Below is my xstyled.cutom.js looks like.
So, a complete guide or a sandbox would be great.
Here's a sandbox https://codesandbox.io/p/sandbox/xstyled-v2-playground-forked-q7dy59