{"success":true,"name":"manage-z-index-with-a-layer-scale-not-bigger-numbers","description":"A frontend element appears under another and you're about to raise its z-index.","category":"ai-brimind","path":"ai-brimind/manage-z-index-with-a-layer-scale-not-bigger-numbers/SKILL.md","file":"SKILL.md","content":"---\nname: manage-z-index-with-a-layer-scale-not-bigger-numbers\ndescription: \"A frontend element appears under another and you're about to raise its z-index.\"\n---\n\n# Manage Z-Index with a Layer Scale, Not Bigger Numbers\n\n## When to use\nYou are fixing an overlap/stacking problem, and about to type an arbitrary high z-index like 999 or 99999.\n\n## Example request\nA dropdown hidden under a sticky header, fixed with z-index: 9999 → next week the modal needs 99999; a defined layer scale (dropdown < sticky < modal < toast) ends the war. Z-index having no effect at all → the element's parent creates its own stacking context; understanding stacking contexts is the real diagnosis. A tooltip trapped inside a card's overflow → no z-index fixes clipping; rendering it at the page root (portal) is the mechanism. Random z-indexes (3, 47, 500) sprinkled per bug → nobody knows the order; central tokens for layers is the cure.\n\n## Instructions\nAct like a city planner for the screen's vertical dimension: every floating element lives on a NAMED floor, and floors are defined once, centrally — never invented mid-bugfix. Set (or find) the project's layer scale as tokens, e.g.: base content (0), dropdowns/popovers (~100), sticky headers (~200), overlays/drawers (~300), modals (~400), toasts (~500) — the exact numbers matter less than the ORDER being written in one place, with every z-index in the codebase referencing a token instead of a magic number. When something stacks wrongly, diagnose before raising anything: (1) is the element in a parent that creates its own stacking context (transform, opacity, filter, position with z-index)? Then its z-index only competes INSIDE that parent — no number escapes it; the fix is restructuring, not escalating; (2) is it clipped by a parent's overflow: hidden? No z-index helps — render the floating element at the document root using the framework's portal mechanism, which exists exactly for dropdowns, tooltips, and modals; (3) only if the element is genuinely on the wrong floor, assign it the correct EXISTING layer token. Adding 9999 is always the wrong answer — it just wins today's fight and guarantees tomorrow's. Finish by naming the element's floor and why it sits there — proving the stack is governed, not escalated.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #417\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}