Open History to see the last commit
1import { ark } from '@ark-ui/solid/factory'
2import { splitProps } from 'solid-js'
3import type { HTMLArkProps } from '@ark-ui/solid/factory'
4import { cn } from '@/utils'
5β
6// Ported from the original shadcn/ui + Radix UI + React component.
7// This wraps an Ark UI factory element and preserves shadcn's Tailwind-based
8// design-system API and styling.
9// https://ui.shadcn.com/
10β
11type LabelProps = HTMLArkProps<'label'> & {
12 'data-slot'?: string
13}
14β
15/**
16 * A styled label for native form controls.
17 *
18 * @example
19 * ```tsx
20 * <Label for="email">Email</Label>
21 * ```
22 */
23function Label(props: LabelProps) {
24 const [local, others] = splitProps(props, ['class', 'data-slot'])
25β
26 return (
27 <ark.label
28 {...others}
29 data-slot={local['data-slot'] ?? 'label'}
30 class={cn(
31 'flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50 peer-data-[disabled]:cursor-not-allowed peer-data-[disabled]:opacity-50 data-disabled:pointer-events-none data-disabled:opacity-50',
32 local.class,
33 )}
34 />
35 )
36}
37β
38export { Label, type LabelProps }