Skip to content

Commit 273032c

Browse files
committed
feat: add base componet type
1 parent 09abccd commit 273032c

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

packages/ui/src/types/other.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import type { ClassValue } from 'clsx';
2+
import type { ReactNode } from 'react';
3+
4+
export type AsTag =
5+
| 'a'
6+
| 'button'
7+
| 'div'
8+
| 'form'
9+
| 'h2'
10+
| 'h3'
11+
| 'img'
12+
| 'input'
13+
| 'label'
14+
| 'li'
15+
| 'nav'
16+
| 'ol'
17+
| 'p'
18+
| 'span'
19+
| 'svg'
20+
| 'ul'
21+
| 'template'
22+
| ({} & string);
23+
24+
export interface PrimitiveProps {
25+
/**
26+
* The element or component this component should render as. Can be overwrite by `asChild`
27+
*
28+
* @defaultValue 'div'
29+
*/
30+
as?: AsTag | ReactNode;
31+
/**
32+
* Change the default rendered element for the one passed as a child, merging their props and behavior.
33+
*
34+
* Read our [Composition](https://www.soybean-ui.com/docs/guides/composition) guide for more details.
35+
*/
36+
asChild?: boolean;
37+
}
38+
39+
export type BaseProps<T> = Omit<T, 'className'> & {
40+
className?: ClassValue;
41+
};

0 commit comments

Comments
 (0)