UNPKG

2.17 kBTypeScriptView Raw
1import { ElementType, ReactElement } from 'react';
2import { PolymorphicPropsWithRef } from 'react-polymorphic-types';
3import { StyleProps, TW, StyleConfig } from 'twind/style';
4export * from 'twind/style';
5
6interface ShouldForwardProp {
7 (prop: string, defaultValidatorFn: (prop: string) => boolean): boolean;
8}
9interface StyledOptions {
10 shouldForwardProp?: ShouldForwardProp;
11}
12interface StyledComponent<Variants, Tag extends ElementType> {
13 <T extends ElementType = Tag>(props: PolymorphicPropsWithRef<StyleProps<Variants>, T>): ReactElement<any, any> | null;
14 /**
15 * CSS Selector associated with the current component.
16 *
17 * ```js
18 * const button = style({
19 * base: {
20 * color: "DarkSlateGray"
21 * }
22 * })
23 *
24 * const article = style({
25 * base: {
26 * [button]: { boxShadow: "0 0 0 5px" }
27 * }
28 * })
29 * ```
30 */
31 toString(): string;
32 /**
33 * CSS Class associated with the current component.
34 *
35 * ```js
36 * const button = style({
37 * base: {
38 * color: "DarkSlateGray"
39 * }
40 * })
41 *
42 * <div className={button.className} />
43 * ```
44 */
45 readonly className: string;
46 /**
47 * CSS Selector associated with the current component.
48 *
49 * ```js
50 * const button = style({
51 * base: {
52 * color: "DarkSlateGray"
53 * }
54 * })
55 *
56 * const Card = styled({
57 * base: {
58 * [Button.selector]: { boxShadow: "0 0 0 5px" }
59 * }
60 * })
61 * ```
62 */
63 readonly selector: string;
64}
65declare function styled<Variants, BaseVariants, Tag extends ElementType>(this: TW | null | undefined | void, base: StyledComponent<BaseVariants, Tag>, config?: StyledOptions & StyleConfig<Variants, BaseVariants>): StyledComponent<BaseVariants & Variants, Tag> & string;
66declare function styled<Variants, Tag extends ElementType = 'div'>(this: TW | null | undefined | void, tag?: Tag, config?: StyledOptions & StyleConfig<Variants>): StyledComponent<Variants, Tag> & string;
67
68export { ShouldForwardProp, StyledComponent, StyledOptions, styled };
69//# sourceMappingURL=react.d.ts.map