Duostrap Transition
A transparent five-phase presence container for Duostrap compositions without implicitly choosing between .fade and .collapse.
Duostrap Transition exposes a transparent five-phase presence state machine (closed → preparing → entering → entered → leaving) while deliberately leaving the choice between classic .fade (150ms linear opacity) and .collapse (height expansion) to the caller.
Preview
Section titled “Preview”The example below pairs duostrap-transition with a classic Duostrap .well stage, .alert-info surface, and 150ms linear .fade opacity across Web Components, React, Vue 3, and Vue 2.
Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<wc-duostrap-transition
id="release-banner"
default-open
appear
class="block transition-opacity duration-150 ease-linear motion-reduce:transition-none"
>
<div
class="rounded-[4px] border border-[#bce8f1] bg-[#d9edf7] px-4 py-3.5 text-[#3a87ad]"
>
<strong>Workspace synced</strong>
<p>Your project tokens and preview artifacts are up to date.</p>
</div>
</wc-duostrap-transition>
<div class="flex gap-2">
<wc-duostrap-button id="enter-btn">Enter</wc-duostrap-button>
<wc-duostrap-button id="leave-btn">Leave</wc-duostrap-button>
<wc-duostrap-button id="complete-btn">
Complete
</wc-duostrap-button>
</div>
<script type="module">
const el = document.querySelector('#release-banner');
document
.querySelector('#enter-btn')
?.addEventListener('click', () =>
el?.getExposes().controls.enter()
);
document
.querySelector('#leave-btn')
?.addEventListener('click', () =>
el?.getExposes().controls.leave()
);
document
.querySelector('#complete-btn')
?.addEventListener('click', () =>
el?.getExposes().controls.complete()
);
</script>Installation
Section titled “Installation”Currently available from workspace source; available starting in 0.3.0-rc.1 and later releases or CLI targets. Import directly from workspace source:
import { transition } from '@proto.ui/prototypes-duostrap/transition';<wc-duostrap-transition default-open appear class="bs-fade-host"> <div class="rounded-[4px] border border-[#bce8f1] bg-[#d9edf7] px-4 py-3.5 text-[#3a87ad]"> <strong>Workspace synced</strong> — Your classic alert surface stays mounted until leaving ends. </div></wc-duostrap-transition>
<style> .bs-fade-host > * { transition: opacity 0.15s linear; } .bs-fade-host[data-transition-state='leaving'] > *, .bs-fade-host[data-transition-state='closed'] > * { opacity: 0; } @media (prefers-reduced-motion: reduce) { .bs-fade-host > * { transition: none; } }</style>- Transparent slot by design:
duostrap-transitionemits zero default paint tokens and retains Base timing defaults so callers can author either.fadeor.collapserecipes without conflicts. - Classic Duostrap metrics: Combine with 4px radii, fixed 14px/20px typography, and classic
#d9edf7/#f5f5f5surfaces. - Reduced motion & Base semantics: Under
prefers-reduced-motion: reduce, automatic waits collapse to0mswhile preserving event and detachment order. Core behavior is inherited from Base Transition.
Examples
Section titled “Examples”Controlled Mode & transitionend Sync
Section titled “Controlled Mode & transitionend Sync” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<wc-duostrap-transition
id="controlled-banner"
enter-duration="450"
leave-duration="350"
class="block transition-opacity duration-150 ease-linear motion-reduce:transition-none"
>
<div
class="rounded-[4px] border border-[#bce8f1] bg-[#d9edf7] px-4 py-3.5 text-[#3a87ad]"
>
Scheduled maintenance at 02:00 UTC.
</div>
</wc-duostrap-transition>
<wc-duostrap-button id="toggle-btn">Toggle open</wc-duostrap-button>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const el = document.querySelector('#controlled-banner');
let open = false;
document
.querySelector('#toggle-btn')
?.addEventListener('click', () => {
open = !open;
setElementProps(el, { open });
});
el?.addEventListener('transitionend', () => {
el.getExposes().controls.complete();
});
</script>Interruption Policies (interrupt)
Section titled “Interruption Policies (interrupt)” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<wc-duostrap-transition
id="interrupt-demo"
default-open
appear
enter-duration="900"
leave-duration="900"
interrupt="reverse"
class="block transition-opacity duration-150 ease-linear motion-reduce:transition-none"
>
<div
class="rounded-[4px] border border-[#bce8f1] bg-[#d9edf7] px-4 py-3.5 text-[#3a87ad]"
>
Compare reverse, wait, and immediate interruption policies.
</div>
</wc-duostrap-transition>
<wc-duostrap-button id="set-wait">
Switch to wait
</wc-duostrap-button>Lifecycle Events & appear
Section titled “Lifecycle Events & appear” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<wc-duostrap-transition
id="lifecycle-demo"
default-open
appear
enter-duration="350"
leave-duration="250"
class="block transition-opacity duration-150 ease-linear motion-reduce:transition-none"
>
<div
class="rounded-[4px] border border-[#bce8f1] bg-[#d9edf7] px-4 py-3.5 text-[#3a87ad]"
>
Observe beforeEnter, afterEnter, beforeLeave, and afterLeave.
</div>
</wc-duostrap-transition>
<script type="module">
const el = document.querySelector('#lifecycle-demo');
for (const name of [
'beforeEnter',
'afterEnter',
'beforeLeave',
'afterLeave',
]) {
el?.addEventListener(name, () =>
console.log(name, el.getExposes().isPresent.get())
);
}
</script>Transition Props
Section titled “Transition Props”Pass open for controlled mode:
| Prop | Type | Default |
|---|---|---|
open | boolean undefined | uncontrolled |
defaultOpen | boolean | false |
appear | boolean | false |
enterDuration | number | 300 |
leaveDuration | number | 200 |
interrupt | 'reverse' 'wait' 'immediate' | reverse |
Exposed States, Events & Methods
Section titled “Exposed States, Events & Methods”| Member | Type / Signature | Description |
|---|---|---|
transitionState | 'closed' 'preparing' 'entering' 'entered' 'leaving' | Current perceptual phase |
isPresent | boolean | Whether view resources stay mounted |
beforeEnter / afterEnter | ExposeEvent<void> | Enter boundary signals |
beforeLeave / afterLeave | ExposeEvent<void> | Leave boundary signals |
enter / leave / complete | () => void | Drive the phase machine (also on controls) |
retainClosedView | (retained: boolean) => void | Retain or detach the closed view |