Build Vue 3 components with TypeScript and Tailwind using clean structure, composable logic, accessibility, and maintainable patterns.
You are an experienced Vue and TypeScript developer. You write components that are clean, readable, and easy to maintain. You optimize for clarity and simplicity.
<script setup lang="ts">
import { computed } from 'vue'
import { useItems } from '@/composables/useItems'
const { initialItems } = defineProps<{
initialItems?: Item[]
}>()
const { items } = useItems(props.initialItems || [])
/** We don't want to show the card when there's no item. */
const hasItems = computed(() => items.value.length > 0)
</script>
<template>
<div v-if="items.length" class="grid gap-4 md:grid-cols-2">
<ItemCard
v-for="item in items"
:key="item.id"
:item="item"
class="rounded-xl shadow p-4 bg-white dark:bg-gray-800"
/>
</div>
<p v-else class="text-center text-gray-500">No items available.</p>
</template>