primevue-mirror/apps/showcase/doc/inputgroup/ButtonDoc.vue

154 lines
4.3 KiB
Vue
Raw Permalink Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>Buttons can be placed at either side of an input element.</p>
</DocSectionText>
2024-05-20 12:14:38 +00:00
<div class="card flex flex-col md:flex-row gap-4">
<InputGroup>
2023-02-28 08:29:30 +00:00
<Button label="Search" />
<InputText placeholder="Keyword" />
</InputGroup>
2023-02-28 08:29:30 +00:00
<InputGroup>
2023-02-28 08:29:30 +00:00
<InputText placeholder="Keyword" />
<InputGroupAddon>
<Button icon="pi pi-search" severity="secondary" variant="text" @click="toggle" />
</InputGroupAddon>
</InputGroup>
<Menu ref="menu" :model="items" popup class="!min-w-fit" />
2023-02-28 08:29:30 +00:00
<InputGroup>
<InputGroupAddon>
<Button icon="pi pi-check" severity="secondary" />
</InputGroupAddon>
2023-02-28 08:29:30 +00:00
<InputText placeholder="Vote" />
<InputGroupAddon>
<Button icon="pi pi-times" severity="secondary" />
</InputGroupAddon>
</InputGroup>
2023-02-28 08:29:30 +00:00
</div>
<DocSectionCode :code="code" />
</template>
<script>
export default {
data() {
return {
items: [{ label: 'Web Search' }, { label: 'AI Assistant' }, { label: 'History' }],
2023-02-28 08:29:30 +00:00
code: {
2023-09-22 12:54:14 +00:00
basic: `
<InputGroup>
2023-02-28 08:29:30 +00:00
<Button label="Search" />
<InputText placeholder="Keyword" />
</InputGroup>
2023-02-28 08:29:30 +00:00
<InputGroup>
2023-02-28 08:29:30 +00:00
<InputText placeholder="Keyword" />
<InputGroupAddon>
<Button icon="pi pi-search" severity="secondary" variant="text" @click="toggle" />
</InputGroupAddon>
</InputGroup>
<Menu ref="menu" :model="items" popup class="!min-w-fit" />
2023-02-28 08:29:30 +00:00
<InputGroup>
<InputGroupAddon>
<Button icon="pi pi-check" severity="secondary" />
</InputGroupAddon>
2023-02-28 08:29:30 +00:00
<InputText placeholder="Vote" />
<InputGroupAddon>
<Button icon="pi pi-times" severity="secondary" />
</InputGroupAddon>
</InputGroup>
2023-10-15 09:38:39 +00:00
`,
2023-09-22 12:54:14 +00:00
options: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex flex-col md:flex-row gap-4">
<InputGroup>
2023-02-28 08:29:30 +00:00
<Button label="Search" />
<InputText placeholder="Keyword" />
</InputGroup>
2023-02-28 08:29:30 +00:00
<InputGroup>
2023-02-28 08:29:30 +00:00
<InputText placeholder="Keyword" />
<InputGroupAddon>
<Button icon="pi pi-search" severity="secondary" variant="text" @click="toggle" />
</InputGroupAddon>
</InputGroup>
<Menu ref="menu" :model="items" popup class="!min-w-fit" />
2023-02-28 08:29:30 +00:00
<InputGroup>
<InputGroupAddon>
<Button icon="pi pi-check" severity="secondary" />
</InputGroupAddon>
2023-02-28 08:29:30 +00:00
<InputText placeholder="Vote" />
<InputGroupAddon>
<Button icon="pi pi-times" severity="secondary" />
</InputGroupAddon>
</InputGroup>
2023-02-28 08:29:30 +00:00
</div>
2023-10-15 09:38:39 +00:00
</template>
<script>
export default {
data() {
return {
items: [{ label: 'Web Search' }, { label: 'AI Assistant' }, { label: 'History' }],
};
},
methods: {
toggle(event) {
this.$refs.menu.toggle(event);
}
}
};
<\/script>
2023-10-15 09:38:39 +00:00
`,
2023-09-22 12:54:14 +00:00
composition: `
<template>
2024-05-20 12:14:38 +00:00
<div class="card flex flex-col md:flex-row gap-4">
<InputGroup>
2023-02-28 08:29:30 +00:00
<Button label="Search" />
<InputText placeholder="Keyword" />
</InputGroup>
2023-02-28 08:29:30 +00:00
<InputGroup>
2023-02-28 08:29:30 +00:00
<InputText placeholder="Keyword" />
<InputGroupAddon>
<Button icon="pi pi-search" severity="secondary" variant="text" @click="toggle" />
</InputGroupAddon>
</InputGroup>
<Menu ref="menu" :model="items" popup class="!min-w-fit" />
2023-02-28 08:29:30 +00:00
<InputGroup>
<InputGroupAddon>
<Button icon="pi pi-check" severity="secondary" />
</InputGroupAddon>
2023-02-28 08:29:30 +00:00
<InputText placeholder="Vote" />
<InputGroupAddon>
<Button icon="pi pi-times" severity="secondary" />
</InputGroupAddon>
</InputGroup>
2023-02-28 08:29:30 +00:00
</div>
2023-10-26 17:53:11 +00:00
</template>
<script setup>
import { ref } from "vue";
const menu = ref();
const items = ref([{ label: 'Web Search' }, { label: 'AI Assistant' }, { label: 'History' }]);
const toggle = (event) => {
menu.value.toggle(event);
};
<\/script>
2023-10-26 17:53:11 +00:00
`
2023-02-28 08:29:30 +00:00
}
};
},
methods: {
toggle(event) {
this.$refs.menu.toggle(event);
}
2023-02-28 08:29:30 +00:00
}
};
</script>