index.tsx 1008 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import type { FC } from 'react'
  2. import cn from '@/utils/classnames'
  3. type Option = {
  4. value: string
  5. text: string
  6. icon?: React.ReactNode
  7. }
  8. type TabSliderProps = {
  9. className?: string
  10. value: string
  11. onChange: (v: string) => void
  12. options: Option[]
  13. }
  14. const TabSliderNew: FC<TabSliderProps> = ({
  15. className,
  16. value,
  17. onChange,
  18. options,
  19. }) => {
  20. return (
  21. <div className={cn(className, 'relative flex')}>
  22. {options.map(option => (
  23. <div
  24. key={option.value}
  25. onClick={() => onChange(option.value)}
  26. className={cn(
  27. 'mr-1 px-3 py-[7px] h-[32px] flex items-center rounded-lg border-[0.5px] border-transparent text-gray-700 text-[13px] font-medium leading-[18px] cursor-pointer hover:bg-gray-200',
  28. value === option.value && 'bg-white border-gray-200 shadow-xs text-primary-600 hover:bg-white',
  29. )}
  30. >
  31. {option.icon}
  32. {option.text}
  33. </div>
  34. ))}
  35. </div>
  36. )
  37. }
  38. export default TabSliderNew