import cx from 'clsx'; import * as React from 'react'; import s from './SegmentedControl.module.scss'; export type SegmentedOption = { value: T; label: React.ReactNode; title?: string; }; type Props = { options: SegmentedOption[]; value: T; onChange: (value: T) => void; label?: string; className?: string; }; /** 分段选择器:一条轨道内若干选项,选中项以白色药丸高亮 */ export function SegmentedControl({ options, value, onChange, label, className, }: Props) { return (
{options.map((o) => { const selected = o.value === value; return ( ); })}
); }