ProjectSwitcher
Qué proyecto de la organización. Con más de siete, un filtro arriba de la lista encuentra uno por nombre.
import { ProjectSwitcher } from '@sypnia/ui/react'
En esta página
Nueve proyectos
Ábrelo y escribe «app».
Código
import { useState } from 'react';
import { ProjectSwitcher } from '@sypnia/ui/react';
// With more than seven projects a filter appears at the top of the list.
const names = ['shop', 'analytics', 'billing', 'marketing-site', 'mobile-app', 'internal-tools', 'staging-copy', 'experiments', 'archive-2025'];
export default function Projects() {
const [project, setProject] = useState('shop');
return <ProjectSwitcher current={project} onChange={setProject} options={names.map((n, i) => ({ id: n, name: n, detail: i % 3 ? 'Frankfurt' : 'Virginia' }))} />;
} Cuándo usarlo
Úsalo cuando
- Después del OrgSwitcher, separado por una barra.
- Muestra la región o el plan en
detail.
No lo uses cuando
- Cambiar de proyecto dentro de un formulario con cambios sin guardar: guarda primero.
Para todos
- El filtro es un buscador; las flechas bajan a la lista.
- Cuando nada coincide, lo dice.
Props
| ProjectSwitcher | Tipo | Por defecto |
|---|---|---|
currentobligatorio | string | |
onChangeobligatorio | (id: string) => void | |
optionsobligatorio | SwitcherOption[] | |
compact | boolean | |
createLabelThe thing to create: «organization». Defaults to `kind`. | string | |
kind | string | |
onCreateAdds «Create …» at the end of the list. | (() => void) | |
onSettingsAdds a settings entry at the end of the list («Organization settings» on the OrgSwitcher). | (() => void) | |
settingsLabelThe words of that entry. | string |