32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import * as React from 'react';
|
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
import { cn } from '../../lib/utils';
|
|
|
|
const inputVariants = cva(
|
|
'w-full bg-input border border-line rounded-[10px] text-ink font-[inherit] placeholder:text-dim/70 shadow-(--inset-shadow) transition-shadow duration-150 focus:outline-none focus:border-accent-text focus:ring-[3px] focus:ring-accent/18 disabled:cursor-not-allowed disabled:opacity-50',
|
|
{
|
|
variants: {
|
|
size: {
|
|
md: 'h-10 px-3 text-[0.95rem]',
|
|
sm: 'h-8 px-3 text-[0.875rem]',
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
size: 'md',
|
|
},
|
|
},
|
|
);
|
|
|
|
export interface InputProps
|
|
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'>,
|
|
VariantProps<typeof inputVariants> {}
|
|
|
|
const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
({ className, size, type, ...props }, ref) => (
|
|
<input type={type} data-slot="input" className={cn(inputVariants({ size }), className)} ref={ref} {...props} />
|
|
),
|
|
);
|
|
Input.displayName = 'Input';
|
|
|
|
export { Input, inputVariants };
|