primevue-mirror/apps/showcase/doc/toggleswitch/TemplateDoc.vue

71 lines
1.7 KiB
Vue
Raw Normal View History

2024-10-02 11:09:40 +00:00
<template>
<DocSectionText v-bind="$attrs">
2024-10-04 06:26:32 +00:00
<p>The <i>handle</i> slot is available to display custom content.</p>
2024-10-02 11:09:40 +00:00
</DocSectionText>
2024-10-04 06:26:32 +00:00
<div class="card flex justify-center gap-4">
2024-10-02 11:09:40 +00:00
<ToggleSwitch v-model="checked">
<template #handle="{ checked }">
2024-10-04 06:26:32 +00:00
<i :class="['!text-xs pi', { 'pi-check': checked, 'pi-times': !checked }]" />
2024-10-02 11:09:40 +00:00
</template>
</ToggleSwitch>
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
checked: false,
code: {
basic: `
<ToggleSwitch v-model="checked">
<template #handle="{ checked }">
2024-10-04 06:26:32 +00:00
<i :class="['!text-xs pi', { 'pi-check': checked, 'pi-times': !checked }]" />
2024-10-02 11:09:40 +00:00
</template>
</ToggleSwitch>
`,
options: `
<template>
<div class="card flex justify-center">
<ToggleSwitch v-model="checked">
<template #handle="{ checked }">
2024-10-04 06:26:32 +00:00
<i :class="['!text-xs pi', { 'pi-check': checked, 'pi-times': !checked }]" />
2024-10-02 11:09:40 +00:00
</template>
</ToggleSwitch>
</div>
</template>
<script>
export default {
data() {
return {
checked: false
}
}
};
<\/script>
`,
composition: `
<template>
<div class="card flex justify-center">
<ToggleSwitch v-model="checked">
<template #handle="{ checked }">
2024-10-04 06:26:32 +00:00
<i :class="['!text-xs pi', { 'pi-check': checked, 'pi-times': !checked }]" />
2024-10-02 11:09:40 +00:00
</template>
</ToggleSwitch>
</div>
</template>
<script setup>
import { ref } from 'vue';
const checked = ref(false);
<\/script>
`
}
};
}
};
</script>