{"summary":"Para que una capa flotante esquive bordes y barras, primero se delimita el espacio útil y luego se posiciona dentro: 4 reglas (menús que se voltean y limitan su altura, diálogos con cabecera y pie fijos, tooltips en 8 direcciones con histéresis, barras fijas) y una demo interactiva.","notes":"<p>Los tooltips, menús, diálogos y demás capas flotantes tienen contenido de longitud variable, y el tamaño de la ventana de la app o del navegador tampoco es fijo: es un detalle que la IA pasa por alto con mucha facilidad al generar interfaces. Si una capa solo sabe abrirse en una dirección fija, en cuanto su disparador se acerca al borde de la ventana, queda al final de una lista larga o pasa bajo la navegación fija al desplazarse, la ventana la recorta o la capa tapa acciones clave. Lo más seguro es delimitar primero su “espacio útil”: la ventana con 16px de margen en cada lado y, para las capas no modales dentro de la página, descontando además la navegación fija superior y las barras fijas inferiores. Además, móntala en el nivel superior mediante un Portal para que ningún contenedor padre la recorte, y vuelve a calcular su posición cada vez que se abra, se desplace la página, cambie el tamaño de la ventana o cambie su propio tamaño.</p>\n        <h2>Si no cabe, se voltea; si es muy alto, se limita</h2>\n        <p>Por defecto, un menú se despliega 8px por debajo de su disparador. Si abajo no hay espacio suficiente y arriba sí, debe voltearse automáticamente y abrirse hacia arriba; un submenú en cascada que no cabe a la derecha pasa del mismo modo a la izquierda, y el punto de partida de la animación de apertura (transform-origin) se traslada también al lado más cercano al disparador. Si tras voltearlo aún se sale por un lateral, desplázalo a lo largo del borde de la ventana hasta devolverlo a la zona segura; si la altura total del menú sigue superando el espacio disponible en ese lado, limita la altura máxima del contenedor a ese espacio, deja que el contenido se desplace por dentro y difumina el borde cortado para indicar que hay más debajo. Además, si con el menú abierto el usuario desplaza la página con el cursor fuera de él, su atención ya ha vuelto a la interfaz principal: el menú debe desvanecerse y cerrarse al instante.</p>\n        <ul>\n        <li><strong>Dónde aplicarlo:</strong> Menús desplegables, menús contextuales, submenús en cascada, selectores (Select)</li>\n        <li><strong>Valores:</strong> 16px desde el borde de la ventana, 8px desde el disparador; voltear, desplazar y limitar la altura con scroll, por este orden; desvanecer al instante al desplazar fuera del menú</li>\n        </ul>\n        <h2>Diálogos con cabecera y pie siempre visibles</h2>\n        <p>Cuando un diálogo con mucho contenido simplemente crece hasta su altura completa y se centra, la fila del título y la de acciones inferiores quedan fuera de la ventana: el usuario pierde el contexto y no encuentra el botón de confirmar. Limita la altura máxima del diálogo a la altura segura de la ventana, fija la barra de título y la barra de acciones inferior, deja que solo se desplace el área de contenido entre ambas y muestra una línea divisoria de 1px cuando el contenido pase bajo el título. Si en un caso concreto el contenido suele ser largo, mejor usa un cajón en lugar de un diálogo: un cajón lateral en escritorio y, en móvil, directamente un cajón inferior a todo el ancho que se despliega de abajo arriba.</p>\n        <ul>\n        <li><strong>Dónde aplicarlo:</strong> Diálogos con listas largas, paneles de ajustes, diálogos de formulario, aceptación de condiciones</li>\n        <li><strong>Valores:</strong> 16px arriba y abajo, filas de título y de acciones fijas, línea divisoria de 1px bajo el título al desplazar el contenido; si el contenido suele ser largo, un cajón lateral o, en móvil, uno inferior a todo el ancho</li>\n        </ul>\n        <h2>Tooltips que cambian de lado y cursor tips con histéresis</h2>\n        <p>Cuando un tooltip se sale por un borde de la ventana, debe voltearse hacia el lado opuesto; si solo se sale un poco cerca de un lateral, también se puede desplazar a lo largo del borde hasta devolverlo al espacio útil, con la flecha apuntando siempre al centro del disparador. Un tooltip con flecha puede tener 8 posiciones predefinidas (arriba, abajo, izquierda, derecha y las cuatro esquinas) y elegir la mejor según el espacio que queda hasta cada borde. En los gráficos, el cursor tip que sigue al puntero se coloca por defecto abajo a la derecha, dejando el cursor completamente libre; cerca del borde derecho pasa al lado izquierdo del cursor, y al volver solo regresa a la derecha cuando el cursor se ha adentrado 24px más allá del punto del cambio. Esa histéresis evita que salte de un lado a otro cuando el cursor se queda cerca del límite. Para saber cuándo usar un tooltip, un cursor tip o un cajón, consulta <a href=\"/es/009-overlays/\">009 Cómo elegir entre tooltips, popovers, cajones y diálogos</a>.</p>\n        <ul>\n        <li><strong>Dónde aplicarlo:</strong> Tooltips de botones de icono y avatares, cursor tips con lecturas de gráficos, tarjetas informativas que siguen al cursor</li>\n        <li><strong>Valores:</strong> 8 posiciones elegidas dinámicamente en tooltips con flecha, flecha apuntando al centro del disparador al desplazarlo; el cursor tip deja libre el cursor y usa 24px de histéresis para volver</li>\n        </ul>\n        <h2>Lejos de la navegación fija y las barras inferiores</h2>\n        <p>Cualquier capa no modal, sobre todo tooltips, menús desplegables y Toasts, debe esquivar los contenedores fijos arriba o abajo (barra de navegación superior, barra de reproducción inferior, barra de pestañas, campo de chat): al calcular el espacio útil, resta primero la altura que ocupan estas barras fijas. Un Toast debe quedarse por encima de la barra inferior para no tapar los controles de reproducción ni la navegación principal; y una capa que no se cierra al desplazar debe ocultarse en cuanto su disparador pasa bajo la navegación fija, en lugar de quedarse flotando sobre la barra de navegación. Un diálogo modal, en cambio, toma el control de toda la pantalla con su fondo oscurecido, así que puede cubrir las barras fijas superior e inferior: su espacio útil es toda la ventana.</p>\n        <ul>\n        <li><strong>Dónde aplicarlo:</strong> Tooltips y menús desplegables cerca de la navegación fija o de la barra inferior, Toasts sobre la barra de reproducción, la barra de pestañas o el campo de texto</li>\n        <li><strong>Valores:</strong> Espacio útil sin las barras fijas superior e inferior, Toast a 16px de la barra inferior, la capa se oculta cuando la navegación fija tapa su disparador</li>\n        </ul>\n        <h2>Dejarlo en manos de la IA</h2>\n        <p>Copia el Prompt de abajo en una herramienta de IA como Claude Code, Codex, Cursor o WorkBuddy: primero revisará los menús, popovers, tooltips, Toasts y diálogos que ya tiene tu proyecto, detectará dónde los recortan los bordes o los tapan las barras fijas y te lo presentará en una tabla; cuando lo confirmes, añadirá el volteo, el desplazamiento, el límite de altura y la lógica para esquivar directamente en los componentes.</p>","prompt":"Check the overlay components my product already has (menus and dropdowns, popovers, tooltips, toasts and dialogs), find where each one breaks at the extremes (by an edge of the window, low on a long page, under a sticky header, above a fixed bottom bar, with long content), and fix the cause in the component, so every place that uses it gets the fix. Diagnose first, and change only what I approve. Work inside my code and components, and do not add a dependency without asking. Every value below is a default to start from.\n\n0. Diagnose\n- List each overlay component, where it is defined (my own, or a library: Floating UI, Radix, MUI, Ant Design), and how it is placed today: preferred side, offset, whether it flips, shifts or caps its height, what it measures against, whether it is rendered in a portal, and when it places itself again.\n- Find what stays fixed on screen (sticky headers, bottom bars) and any clipping or scrolling container between an overlay and the window.\n- Find the places where each one fails: the last rows of a long list, the right end of a header, inside a scrolling panel, a dialog with its longest content. Trace each failure to its cause in the component, not to the page it shows up on.\n\n1. The room\n- Every overlay stays inside the window less 16px on each side. In the page, also less the sticky header and any fixed bottom bar; modal layers cover the bars. Render overlays in a portal.\n- Place it again on open, on scroll, on resize and when its own size changes, not once only.\n\n2. Menus and dropdowns\n- 8px from the trigger. When the preferred side has no room, flip to the other side, then shift along it into the room.\n- When it is still too tall, cap it to the room and let it scroll inside.\n- When the page scrolls while the pointer is outside the menu, fade it out and close it.\n- With Floating UI: offset(8), flip, shift and size with padding 16, and autoUpdate.\n\n3. Dialogs\n- No taller than the window less 16px. The title bar and the button bar stay put; only the content between them scrolls, with a 1px line where it passes under them.\n- Where the content is often long, suggest a side drawer on desktop and a full-width bottom sheet on phones, and ask me before changing.\n\n4. Tooltips\n- By an edge, flip to the opposite side or shift along it; the arrow keeps pointing at the trigger.\n- With an arrow, choose among 8 placements (above, below, left, right and the four corners) by the room on each side.\n- A tooltip that follows the pointer sits clear of the cursor, moves to its other side by an edge, and comes back only once the pointer is 24px further in.\n\n5. Fixed bars\n- No overlay, tooltips above all, covers a sticky header or a bottom bar. Toasts sit 16px above the bottom bar. An overlay whose trigger scrolls under the header hides with it.\n\n6. Report and check\n- Before changing anything, give me one table, one row per component: | Component | Used in | Today | Cases that fail | Cause | Fix | Values |. Ask me which rows to change.\n- Afterwards, go back to every failing case and check that it opens whole, inside the room.","skill":"/skills/kubai-overlay-avoidance/SKILL.md","skillText":"# 浮层避让的定位规则\n\n《999 个小技巧，让你 Vibe 的产品更有质感》第 026 期 · @kubai087\n\n在用户的项目里按下面的要求改造。要求以用户的口吻写成：文中的 I、me、my 指用户；写着要先问的地方，先停下来问用户再继续。\n\n## 改造要求\n\nCheck the overlay components my product already has (menus and dropdowns, popovers, tooltips, toasts and dialogs), find where each one breaks at the extremes (by an edge of the window, low on a long page, under a sticky header, above a fixed bottom bar, with long content), and fix the cause in the component, so every place that uses it gets the fix. Diagnose first, and change only what I approve. Work inside my code and components, and do not add a dependency without asking. Every value below is a default to start from.\n\n0. Diagnose\n- List each overlay component, where it is defined (my own, or a library: Floating UI, Radix, MUI, Ant Design), and how it is placed today: preferred side, offset, whether it flips, shifts or caps its height, what it measures against, whether it is rendered in a portal, and when it places itself again.\n- Find what stays fixed on screen (sticky headers, bottom bars) and any clipping or scrolling container between an overlay and the window.\n- Find the places where each one fails: the last rows of a long list, the right end of a header, inside a scrolling panel, a dialog with its longest content. Trace each failure to its cause in the component, not to the page it shows up on.\n\n1. The room\n- Every overlay stays inside the window less 16px on each side. In the page, also less the sticky header and any fixed bottom bar; modal layers cover the bars. Render overlays in a portal.\n- Place it again on open, on scroll, on resize and when its own size changes, not once only.\n\n2. Menus and dropdowns\n- 8px from the trigger. When the preferred side has no room, flip to the other side, then shift along it into the room.\n- When it is still too tall, cap it to the room and let it scroll inside.\n- When the page scrolls while the pointer is outside the menu, fade it out and close it.\n- With Floating UI: offset(8), flip, shift and size with padding 16, and autoUpdate.\n\n3. Dialogs\n- No taller than the window less 16px. The title bar and the button bar stay put; only the content between them scrolls, with a 1px line where it passes under them.\n- Where the content is often long, suggest a side drawer on desktop and a full-width bottom sheet on phones, and ask me before changing.\n\n4. Tooltips\n- By an edge, flip to the opposite side or shift along it; the arrow keeps pointing at the trigger.\n- With an arrow, choose among 8 placements (above, below, left, right and the four corners) by the room on each side.\n- A tooltip that follows the pointer sits clear of the cursor, moves to its other side by an edge, and comes back only once the pointer is 24px further in.\n\n5. Fixed bars\n- No overlay, tooltips above all, covers a sticky header or a bottom bar. Toasts sit 16px above the bottom bar. An overlay whose trigger scrolls under the header hides with it.\n\n6. Report and check\n- Before changing anything, give me one table, one row per component: | Component | Used in | Today | Cases that fail | Cause | Fix | Values |. Ask me which rows to change.\n- Afterwards, go back to every failing case and check that it opens whole, inside the room.\n"}