brumate/ui

Transition

Animates content in and out. It keeps the content in the page until its leave ends, which CSS cannot do for content that is removed.

The note fades and slides as it comes and goes.
<script>
  import { $signal } from 'brumate/signals';
  import Button from '@brumate/ui/Button.brm';
  import Transition from '@brumate/ui/Transition.brm';

  let shown = $signal(true);
</script>

<Button class="ui-button" onPress=(() => (shown = !shown))>{shown ? 'Hide' : 'Show'} the note</Button>
<Transition show=shown class="ui-note">The note fades and slides as it comes and goes.</Transition>

Other parts run the same steps with their transition prop: DisclosurePanel, Popover, ModalOverlay, Tooltip and ToastRegion. They show the same attributes, so the CSS below works for each of them.

.note {
  transition: opacity 0.25s;
}

.note[data-closed] {
  opacity: 0;
}

Reduced motion

Reduced motion is for the CSS: a transition that a prefers-reduced-motion query removes has nothing to wait for.

@media (prefers-reduced-motion: reduce) {
  .note {
    transition: none;
  }
}

TransitionChild

An element inside a Transition, or inside a part with transition, that moves with it. It takes the props of Transition, except show.

<Transition show=open class="backdrop">
  <TransitionChild class="panel">The panel slides in after the backdrop fades in.</TransitionChild>
</Transition>