Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

1.3 KB
Raw Blame
'use client'
import { Checkbox } from '@langgenius/dify-ui/checkbox'
import { cn } from '@langgenius/dify-ui/cn'
import { Infotip, InfotipContent, InfotipTrigger } from '@langgenius/dify-ui/infotip'
import { useId } from 'react'

type Props = Readonly<{
  className?: string
  isChecked: boolean
  onChange: (isChecked: boolean) => void
  label: string
  labelClassName?: string
  tooltip?: string
}>

export default function CheckboxWithLabel({
  className = '',
  isChecked,
  onChange,
  label,
  labelClassName,
  tooltip,
}: Props) {
  const labelId = useId()

  return (
    <div className={cn(className, 'flex h-7 items-center')}>
      <label className="flex min-w-0 cursor-pointer items-center">
        <Checkbox checked={isChecked} onCheckedChange={(checked) => onChange(checked)} />
        <span
          id={labelId}
          className={cn(
            'ml-2 min-w-0 text-left text-sm font-normal text-text-secondary',
            labelClassName,
          )}
        >
          {label}
        </span>
      </label>
      <div className="ml-1 flex min-w-0 items-center">
        {tooltip && (
          <Infotip>
            <InfotipTrigger aria-labelledby={labelId} />
            <InfotipContent aria-labelledby={labelId} className="w-50">
              {tooltip}
            </InfotipContent>
          </Infotip>
        )}
      </div>
    </div>
  )
}