collapsible-sidebar
БесплатноБез исполняемых скриптовНе проверенUse this when building a sidebar that collapses to an icon rail, or any element that toggles between shown and hidden. Labels fade out before display:none and…
от julianromli★ 245 звёзд на GitHubОб этом скилле
Collapsible sidebar (allow-discrete fade)
Source: @nonzeroexitcode (Daniel Petho) on Threads, https://www.threads.com/@nonzeroexitcode/post/De4xkSrE0Ze. Working demo: examples/index.html (normal vs allow-discrete, side by side).
The problem
display is a discrete property. It has no in-between value. When a label goes to display: none, it disappears in the first frame, and any opacity transition on it never shows.
transition-behavior: allow-discrete makes the browser hold the old display value until the transition ends. Then display: none applies. @starting-style gives the entry a start value, so the element fades in when it comes back.
Recipe
- Sidebar width: transition
widthbetween the open and collapsed sizes. Use 200ms with a strong ease-out,cubic-bezier(0.23, 1, 0.32, 1). Setoverflow: hiddenon the sidebar. - Label: put the text in its own element (
<span class="label">). Keep the icon outside it. Icons never move or fade. - Label transition:
.label { opacity: 1; transition: opacity 150ms ease-out, display 150ms allow-discrete; } .sidebar[data-collapsed] .label { opacity: 0; display: none; } @starting-style { .label { opacity: 0; } } - Keep the
displayduration the same as theopacityduration. If the display duration is shorter, the fade is cut off. - Put the
@starting-styleblock after the base rule. It needs equal or higher specificity than the rule it starts. - Rows: fixed height (32px desktop, 44px touch),
white-space: nowrap, so the text never wraps while the width animates.
Tailwind v4
transition-discretesetstransition-behavior: allow-discrete.- The
starting:variant writes@starting-style, for examplestarting:opacity-0. - Example label:
transition-[opacity,display] duration-150 ease-out transition-discrete starting:opacity-0 group-data-collapsed:hidden group-data-collapsed:opacity-0.
Accessibility
- The toggle is a
<button>witharia-expandedandaria-controlsthat points to the sidebar id. Its label changes with the state ("Collapse sidebar" / "Expand sidebar"). - A label under
display: nonegives no accessible name. Putaria-labelon each link, plustitle(or a real tooltip) for mouse users on the collapsed rail. - Keep a visible
:focus-visiblering on every link and on the toggle. - Under
prefers-reduced-motion: reduce, settransition: noneon the width and the label. The state still changes at once. - Hover styles go inside
@media (hover: hover), so touch taps do not leave a stuck hover.
When it does not apply
allow-discreteworks only on an element that stays in the DOM and changesdisplay(orcontent-visibility, oroverlayfor<dialog>and[popover]). It does not help an element that React or another framework unmounts. For an unmounted element, keep it mounted and hide it with CSS, or render a short-lived inert exit copy, or use an animation library with exit support.- Do not animate
widthon a large, content-heavy layout where relayout is costly. Then animatetransformon an overlay sidebar instead.
Browser support
Baseline 2024: Chrome 117, Safari 17.4, Firefox 129. A browser without support hides and shows the label at once, with no fade. That is a safe fallback; no polyfill is needed.
Verify
- Open the page in Chromium. Collapse. Sample the label's computed
displayandopacityevery frame for 200ms. Expected:displaystays visible while opacity goes 1 to 0, thendisplay: noneat about 150ms. - Expand. Expected: opacity starts at 0 and rises to 1.
- With reduced motion on: no transition, the state changes in one frame.
- Tab through the collapsed rail: every link has a name and a visible focus ring.
Установить collapsible-sidebar в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл collapsible-sidebar?
Use this when building a sidebar that collapses to an icon rail, or any element that toggles between shown and hidden. Labels fade out before display:none and fade in on show, using CSS transition-behavior allow-discrete plus @starting-style, with no JS animation library.
Как установить скилл collapsible-sidebar?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл collapsible-sidebar запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic