ComponentesComponents

Drawer

Panel lateral para filtros, ajustes o detalles.Side panel for filters, settings or details.

DiseñoDesign: coss ui (MIT) · sheet.tsxMITherramienta · densidaddensity media · sobriaMarkdownJSON

CódigoCode

<button class="c-btn c-btn--outline" type="button" commandfor="drawer-filters" command="show-modal">Abrir filtros</button>

<dialog class="c-drawer" id="drawer-filters" aria-labelledby="drawer-title" aria-describedby="drawer-desc" closedby="any">
  <form class="c-drawer__form" method="dialog">
    <div class="c-drawer__header">
      <h2 class="c-drawer__title" id="drawer-title">Filtros</h2>
      <p class="c-drawer__description" id="drawer-desc">Ajusta qué proyectos ves en la lista.</p>
    </div>
    <div class="c-drawer__panel">
      <div class="c-field"><label class="c-label" for="drawer-q">Buscar</label><span class="c-input"><input class="c-input__field" id="drawer-q" type="search" placeholder="Nombre del proyecto"></span></div>
      <div class="c-field"><label class="c-label" for="drawer-owner">Responsable</label><span class="c-input"><input class="c-input__field" id="drawer-owner" placeholder="Cualquiera"></span></div>
    </div>
    <div class="c-drawer__footer">
      <button class="c-btn c-btn--ghost" value="reset">Limpiar</button>
      <button class="c-btn c-btn--primary" value="apply">Aplicar</button>
    </div>
    <button class="c-btn c-btn--ghost c-btn--icon c-drawer__close" type="button" commandfor="drawer-filters" command="close" aria-label="Cerrar"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg></button>
  </form>
</dialog>

«Todo» trae tokens, dependencias y componente en un solo archivo, listo para abrir o dárselo a un agente.“All” bundles tokens, dependencies and the component in one file, ready to open or hand to an agent.

InstalaciónInstallation

  1. Agrega una vezAdd once tokens.css (colores, radios, tema oscuro).(colors, radii, dark theme).
  2. Agrega también:Also add: BotónButton, Campo de textoText field, DiálogoDialog.
  3. Copia los archivos:Copy the files: drawer.html, drawer.css.
  4. Para el tema oscuro, pon la claseFor the dark theme, add the class dark ento <html>.

Cuándo usarloWhen to use it

ÚsaloUse it

  • Para tareas secundarias sin perder la página de vista.
  • For secondary tasks without losing the page.

Mejor noAvoid

  • Para confirmaciones cortas: usa un diálogo.
  • For short confirmations: use a dialog.

AccesibilidadAccessibility

dialog
EscCierraCloses
TabRecorre solo el panelCycles within the panel
  • También es <dialog> nativo: foco atrapado, Esc y clic fuera cierran.
  • Entra desde la derecha; con «reducir movimiento» aparece sin deslizar.
  • Also a native <dialog>: focus trapped, Esc and outside click close it.
  • Slides in from the right; with reduced motion it appears without sliding.

Cómo probarloHow to test it

  • Abre «Filtros», pulsa Esc: el foco vuelve a «Abrir filtros».
  • Open “Filters”, press Esc: focus returns to “Open filters”.

CréditosCredits