When adding expandable/conditional UI in React/TSX, keep the structure consistent within the surrounding component and ensure accessibility attributes are applied uniformly.
Apply this standard:
AdvancedPathSettings) to reduce duplication once it’s repeated.Example (toggle + conditional section, with consistent ARIA):
function AdvancedToggle({ showAdvanced, setShowAdvanced }: {
showAdvanced: boolean;
setShowAdvanced: (v: boolean) => void;
}) {
const id = "advanced-settings";
return (
<>
<button
type="button"
className="text-sm text-text-muted hover:text-text-primary flex items-center gap-1"
aria-expanded={showAdvanced}
aria-controls={id}
onClick={() => setShowAdvanced(!showAdvanced)}
>
<span
className={`transition-transform ${showAdvanced ? "rotate-90" : ""}`}
aria-hidden="true"
>
▶
</span>
advanced settings
</button>
{showAdvanced && (
<div id={id} className="flex flex-col gap-3 pl-2 border-l-2 border-border">
{/* advanced inputs here */}
</div>
)}
</>
);
}
Enter the URL of a public GitHub repository