Design System

Component usage guide template

Browse Components

rhf

RHF Single Combobox

React Hook Form wrapper cho SingleCombobox với hỗ trợ validation và error handling tích hợp.

1. Import
Import RHFSingleCombobox component từ design system.
import { RHFSingleCombobox } from "@/design-system/components/rhf";
2. Props
RHFSingleCombobox component props.
PropTypeDefault
controlControl<T>--
namePath<T>--
optionsComboboxBaseOption[]--
labelstring | React.ReactNode--
descriptionstring--
requiredbooleanfalse
disabledbooleanfalse
placeholderstringChọn...
showMenuCodebooleantrue
showSelectedCodebooleanfalse
searchPlaceholderstringTìm kiếm...
emptyMessagestringKhông tìm thấy kết quả
callback(newValue: string | number | undefined, option: TOption | undefined) => void--
wrapperClassNamestring--
labelClassNamestring--
descriptionClassNamestring--
errorClassNamestring--
3. Usages
Các pattern và cấu hình RHFSingleCombobox phổ biến.
Chọn phòng ban
import { RHFSingleCombobox } from "@/design-system/components/rhf";
import { useForm } from "react-hook-form";
import type { ComboboxBaseOption } from "@/design-system/components/ui/single-combobox";

const departments: ComboboxBaseOption[] = [
  { id: '1', code: 'IT', name: 'Công nghệ thông tin' },
  { id: '2', code: 'FIN', name: 'Tài chính' },
  { id: '3', code: 'HR', name: 'Nhân sự' },
];

export function ExampleCombobox() {
  const { control } = useForm({
    defaultValues: {
      department: undefined,
    },
  });

  return (
    <RHFSingleCombobox
      control={control}
      name="department"
      options={departments}
      label="Phòng ban"
      placeholder="Chọn phòng ban"
    />
  );
}