Vue ટ્યુટોરિયલ
ટાઇપ કરેલા props સાથેના Vue 3 એક-ફાઇલ ઘટકો, defineModel
બે-તરફી બાઇન્ડિંગ, અને v-bind="$attrs" પાસ-થ્રુ.
તમે શું બનાવશો
એક નાનું સંપર્ક ફોર્મ — લેબલ સાથેનું ક્ષેત્ર, સબમિટ બટન, v-model
બાઇન્ડિંગ, સાચું કીબોર્ડ અને સ્ક્રીન-રીડર વર્તન — પહેલાં સાદું, પછી શૈલીબદ્ધ, લગભગ 10 મિનિટમાં.
શરૂ કરતા પહેલાં
તમને git, Node 22 કે નવું, અને pnpm 10 કે નવું જોઈએ. કોઈ પણ Vue 3 પ્રોજેક્ટ ચાલશે — Nuxt, Vite અથવા સાદું Vue.
પગલું 1 — કોડ મેળવો
git clone https://github.com/LilyDesignSystem/lily-design-system
cd lily-design-system/lily-design-system-vue-headless
pnpm install
pnpm test # vitest + @testing-library/vue
pnpm run storybook # browse all 571 components
ઘટકો અહીં સપાટ ફાઇલો તરીકે છે: components/ —
Button.vue, TextInput.vue — દરેકની બાજુમાં તેનું પરીક્ષણ, story અને દસ્તાવેજો. જે ફાઇલો જોઈએ તે કૉપી કરો, અથવા રિપો લાવો.
પગલું 2 — તમારો પહેલો ઘટક
<script setup>
import Button from "lily-design-system-vue-headless/components/Button.vue";
</script>
<template>
<Button @click="save">Save</Button>
</template>
આ દર્શાવે છે <button class="button" type="button">. Props બીજા ફ્રેમવર્ક સાથે મેળ ખાય છે: type, disabled,
pressed, label, ઉપરાંત બાકી બધા માટે ગુણધર્મ પાસ-થ્રુ.
પગલું 3 — એક નાનું ફોર્મ બનાવો
<script setup>
import { ref } from "vue";
import Form from ".../components/Form.vue";
import Field from ".../components/Field.vue";
import TextInput from ".../components/TextInput.vue";
import Button from ".../components/Button.vue";
const name = ref("");
</script>
<template>
<Form @submit="handleSubmit">
<Field label="Full name" required>
<TextInput id="name" label="Full name" v-model="name" required />
</Field>
<Button type="submit">Save</Button>
</Form>
</template>
Field દેખાતા label ને પોતાના prop તરીકે, અંદર મૂકેલા લેબલ ઘટક તરીકે નહીં — તેને એક વાર આપો, પર
Fieldઅને TextInputનું
label સુલભ નામ પૂરું પાડે છે.
2026-08-29 ના રોજ ચકાસ્યું: અગાઉના મુસદ્દાએ અલગ Label ની અંદર Fieldની અંદર મૂક્યો હતો, જેનાથી
બે લેબલ (એક ખાલી) દેખાયા કારણ કે Field પહેલેથી પોતાનું label prop — ચોક્કસ ટુકડો કમ્પાઇલ કરીને ખબર પડી. રૂટ
સંયુક્ત સંપર્ક-ફોર્મ રૂટ
એ જ પેટર્ન છે, સાચા e2e અને axe પરીક્ષણોથી ચકાસાયેલ.
TextInput વાપરે છે defineModel, તેથી સાદું
v-model તરત કામ કરે છે.
તમારું કામ તપાસો: એપ ચલાવો અને ફોર્મ સાદું દેખાય છે — બરાબર ધાર્યા મુજબ: શૈલી હજી આગળ છે. દબાવો Tab: ફોકસ દરેક નિયંત્રણમાંથી પસાર થાય છે, લેબલ જાહેર થાય છે અને સબમિટ કામ કરે છે. વર્તન પૂર્ણ છે; દેખાવ તમારો છે અને આગલું પગલું છે.
પગલું 4 — તેને શૈલી આપો
ક્લાસ હૂકને શૈલી આપો — .button, .text-input,
.label, .field — તમારી સ્ટાઇલશીટમાં, અથવા તૈયાર થીમ અહીં લિંક કરો index.html / nuxt.config:
<link rel="stylesheet" href="/themes/nord.css" />
પગલું 5 — બધું કામ કરતું જુઓ
Nuxt ઉદાહરણ એપ સંપૂર્ણ કેટલોગ શૈલીબદ્ધ અને નિદર્શન સાથે છે, Playwright e2e અને axe-core આધારરેખા સાથે:
git clone https://github.com/LilyDesignSystem/lily-design-system
cd lily-design-system/lily-design-system-vue-nuxt-examples
pnpm install && pnpm run dev
આગળનાં પગલાં
- થીમ — Vue theme-picker સહાયક સાથે ચાલતી વખતે બદલવું.
- પસંદગી સહાયકો — ભાષા અને લખાણનું કદ.
- ઘટક કેટલોગ — દરેક ઘટક માટે ગુણધર્મો, ARIA અને કીબોર્ડ.
રસ્તામાં પ્રશ્નો છે? મદદ પૃષ્ઠ જવાબોથી ભરેલું છે — અને જો કોઈ પગલું વધુ સ્પષ્ટ થઈ શકે, અમને કહો અને અમે ખુશીથી ટ્યુટોરિયલ સુધારીશું.