Swap

Examples

Swap text

<dv-swap on="ON" off="OFF" />
vue

Swap volume icons

export default {
  setup: () => {
    return () => (
      <dv-swap
        on={() => <IconVolumeHigh size="48px" />}
        off={() => <IconVolumeMute size="48px" />}
      />
    );
  },
};
tsx

Swap icons with rotate effect

<dv-swap animation="rotate">
  <template v-slot:on>
    <IconSunny size="48px" />
  </template>
  <template v-slot:off>
    <IconMoon size="48px" />
  </template>
</dv-swap>
vue

Swap with flip effect

export default {
  setup: () => {
    return () => (
      <div class="text-center text-9xl">
        <dv-swap on="😈" off="😇" animation="flip" />
      </div>
    );
  },
};
tsx

Controlled swap

 / 
import { ref } from 'vue';

export default {
  setup: () => {
    const active = ref(false);
    return () => (
      <div class="text-center">
        <div class="py-2">
          <dv-button onClick={() => (active.value = true)}>on</dv-button>
          &nbsp;/&nbsp;
          <dv-button onClick={() => (active.value = false)}>off</dv-button>
        </div>
        <div class="text-9xl">
          <dv-swap on="🥳" off="😭" animation="flip" active={active.value} />
        </div>
      </div>
    );
  },
};
tsx

Swap

Attributes

namedescriptiontypedefault
onrender on--
offrender off--
tagwrap elemnt tagstringlabel
animationanimation effectrotate, flip-
activeswap active statusboolean-
onChangeswap active status change eventFunction-

Solts

namedescription
onrender on
offrender off