tab.tsx 868 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import type { FC } from 'react'
  2. type TabProps = {
  3. active: string
  4. onSelect: (active: string) => void
  5. }
  6. const Tab: FC<TabProps> = ({
  7. active,
  8. onSelect,
  9. }) => {
  10. const tabs = [
  11. {
  12. key: 'all',
  13. text: 'All',
  14. },
  15. {
  16. key: 'added',
  17. text: 'Added',
  18. },
  19. {
  20. key: 'build-in',
  21. text: 'Build-in',
  22. },
  23. ]
  24. return (
  25. <div className='flex items-center'>
  26. {
  27. tabs.map(tab => (
  28. <div
  29. key={tab.key}
  30. className={`
  31. flex items-center mr-1 px-[5px] h-[18px] rounded-md text-xs cursor-pointer
  32. ${active === tab.key ? 'bg-gray-200 font-medium text-gray-900' : 'text-gray-500 font-normal'}
  33. `}
  34. onClick={() => onSelect(tab.key)}
  35. >
  36. {tab.text}
  37. </div>
  38. ))
  39. }
  40. </div>
  41. )
  42. }
  43. export default Tab