Context
shadcn/uiμ Sidebarμμλ Input μ»΄ν¬λνΈλ₯Ό μ¬μ©νλ€. μ΄ Input μ»΄ν¬λνΈλ μ¬μ΄λλ°μ μ’
μλλ μ»΄ν¬λνΈκ° μλ λ€λ₯Έ κ³³μμλ λ²μ©μ μΌλ‘ μ¬μ© λ μ μκΈ°μ λΆμκ³Ό μ΄ν΄κ° νμνλ€.
Agenda
β’
shadcnμ Input μ»΄ν¬λνΈλ₯Ό λΆμνκ³ μ΄ν΄νλ κ²μ λͺ©νλ‘ ν¨
Contents
import { cn } from '@ui/lib/utils';
import type * as React from 'react';
function Input({ className, type, ...props }: React.ComponentProps<'input'>) {
return (
<input
type={type}
data-slot='input'
className={cn(
'file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',
'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]',
'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive',
className,
)}
{...props}
/>
);
}
export { Input };
TypeScript
볡μ¬
μλ shadcn/uiμ κΈ°λ³Έ Input μ»΄ν¬λνΈμ΄λ€. input νκ·Έμμ μ¬μ©νλ νλΌλ―Έν°λ₯Ό κ·Έλλ‘ λ°μμ¬ μ μλ€. classNameμλ μ€νμΌλ§κ³Ό κ΄λ ¨ λ μμ±λ€μ΄ μ
λ ₯μ΄ λμ΄μκ³ , aria-invalidμ νμ©νμ¬ νΌ κ²μ¦μ μ€νμΌλ§μ μ 곡νλ€. selection μ νμλ λλκ·Έλ μ ν μ μ μ© λλ μμ±μ΄λ€.