|
1
|
"use client" |
|
2
|
|
|
3
|
import { cva, type VariantProps } from "cva" |
|
4
|
import { Label as RadixLabel } from "radix-ui" |
|
5
|
import * as React from "react" |
|
6
|
|
|
7
|
import { clx } from "@/utils/clx" |
|
8
|
|
|
9
|
const labelVariants = cva({ |
|
10
|
base: "font-sans", |
|
11
|
variants: { |
|
12
|
size: { |
|
13
|
xsmall: "txt-compact-xsmall", |
|
14
|
small: "txt-compact-small", |
|
15
|
base: "txt-compact-medium", |
|
16
|
large: "txt-compact-large", |
|
17
|
}, |
|
18
|
weight: { |
|
19
|
regular: "font-normal", |
|
20
|
plus: "font-medium", |
|
21
|
}, |
|
22
|
}, |
|
23
|
defaultVariants: { |
|
24
|
size: "base", |
|
25
|
weight: "regular", |
|
26
|
}, |
|
27
|
}) |
|
28
|
|
|
29
|
interface LabelProps |
|
30
|
extends React.ComponentPropsWithoutRef<"label">, |
|
31
|
VariantProps<typeof labelVariants> {} |
|
32
|
|
|
33
|
/** |
|
34
|
* This component is based on the [Radix UI Label](https://www.radix-ui.com/primitives/docs/components/label) primitive. |
|
35
|
*/ |
|
36
|
const Label = React.forwardRef<HTMLLabelElement, LabelProps>( |
|
37
|
({ |
|
38
|
className, |
|
39
|
/** |
|
40
|
* The label's size. |
|
41
|
*/ |
|
42
|
size = "base", |
|
43
|
/** |
|
44
|
* The label's font weight. |
|
45
|
*/ |
|
46
|
weight = "regular", |
|
47
|
...props |
|
48
|
}: LabelProps, ref) => { |
|
49
|
return ( |
|
50
|
<RadixLabel.Root |
|
51
|
ref={ref} |
|
52
|
className={clx(labelVariants({ size, weight }), className)} |
|
53
|
{...props} |
|
54
|
/> |
|
55
|
) |
|
56
|
} |
|
57
|
) |
|
58
|
Label.displayName = "Label" |
|
59
|
|
|
60
|
export { Label } |