index.tsx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import type { FC } from 'react'
  2. import cn from '@/utils/classnames'
  3. import style from './page.module.css'
  4. type Option = {
  5. value: string
  6. text: string
  7. icon?: React.ReactNode
  8. }
  9. type TabSliderProps = {
  10. className?: string
  11. value: string
  12. onChange: (v: string) => void
  13. options: Option[]
  14. }
  15. const TabSliderNew: FC<TabSliderProps> = ({
  16. className,
  17. value,
  18. onChange,
  19. options,
  20. }) => {
  21. return (
  22. <div className={cn(className, 'relative flex')}>
  23. {options.map(option => (
  24. <div
  25. key={option.value}
  26. onClick={() => onChange(option.value)}
  27. className={cn(
  28. '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',
  29. value === option.value &&style.tabcolor,'bg-white border-gray-200 shadow-xs hover:bg-white ',
  30. )}
  31. >
  32. {option.icon}
  33. {option.text}
  34. </div>
  35. ))}
  36. </div>
  37. )
  38. }
  39. export default TabSliderNew