primevue-mirror/doc/inputotp/TemplateDoc.vue

125 lines
2.8 KiB
Vue
Raw Normal View History

2024-02-22 06:40:19 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>Define a template with your own UI elements with bindings to the provided events and attributes to replace the default design.</p>
</DocSectionText>
<div class="card flex justify-content-center">
<InputOtp v-model="value">
<template #default="{ attrs, events }">
<input type="text" v-bind="attrs" v-on="events" class="custom-otp-input" />
</template>
</InputOtp>
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
value: null,
code: {
basic: `
<InputOtp v-model="value">
<template #default="{ attrs, events }">
<input type="text" v-bind="attrs" v-on="events" class="custom-otp-input" />
</template>
</InputOtp>
`,
options: `
<template>
<div class="card flex justify-content-center">
<InputOtp v-model="value">
<template #default="{ attrs, events }">
<input type="text" v-bind="attrs" v-on="events" class="custom-otp-input" />
</template>
</InputOtp>
</div>
</template>
<script>
export default {
data() {
return {
value: null
}
}
};
<\/script>
<style scoped>
.custom-otp-input {
width: 40px;
font-size: 36px;
border: 0 none;
appearance: none;
text-align: center;
transition: all 0.2s;
background: transparent;
2024-03-27 08:30:38 +00:00
border-bottom: 2px solid var(--p-inputtext-border-color);
2024-02-22 06:40:19 +00:00
}
.custom-otp-input:focus {
outline: 0 none;
2024-03-27 08:30:38 +00:00
border-bottom-color: var(--p-primary-color);
2024-02-22 06:40:19 +00:00
}
<\/style>
`,
composition: `
<template>
<div class="card flex justify-content-center">
<InputOtp v-model="value">
<template #default="{ attrs, events }">
<input type="text" v-bind="attrs" v-on="events" class="custom-otp-input" />
</template>
</InputOtp>
</div>
</template>
<script setup>
import { ref } from 'vue';
const value = ref(null);
<\/script>
<style scoped>
.custom-otp-input {
width: 40px;
font-size: 36px;
border: 0 none;
appearance: none;
text-align: center;
transition: all 0.2s;
background: transparent;
2024-03-27 08:30:38 +00:00
border-bottom: 2px solid var(--p-inputtext-border-color);
2024-02-22 06:40:19 +00:00
}
.custom-otp-input:focus {
outline: 0 none;
2024-03-27 08:30:38 +00:00
border-bottom-color: var(--p-primary-color);
2024-02-22 06:40:19 +00:00
}
<\/style>
`
}
};
}
};
</script>
<style scoped>
.custom-otp-input {
width: 40px;
font-size: 36px;
border: 0 none;
appearance: none;
text-align: center;
transition: all 0.2s;
background: transparent;
2024-03-27 08:30:38 +00:00
border-bottom: 2px solid var(--p-inputtext-border-color);
2024-02-22 06:40:19 +00:00
}
.custom-otp-input:focus {
outline: 0 none;
2024-03-27 08:30:38 +00:00
border-bottom-color: var(--p-primary-color);
2024-02-22 06:40:19 +00:00
}
</style>