Skip to content

Commit

Permalink
fix(docs): add example for QField tag property.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedjas1m committed Mar 26, 2024
1 parent a02930b commit f3fdbd6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docs/src/examples/QField/TagWrapper.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<template>
<div class="q-pa-md">
<div class="q-gutter-y-md column" style="max-width: 300px">
<q-field label="Custom Component Wrapper" stack-label>

<template v-slot:control>
<div class="self-center full-width no-outline" tabindex="0">{{divText}}</div>
</template>
</q-field>

<q-field v-model="labelText" tag="label" label="Form Control Field Wrapper" stack-label clearable>
<template v-slot:control="{ id, modelValue, emitValue }">
<input :id="id" class="q-field__input" :value="modelValue" @input="e => emitValue(e.target.value)">
</template>
</q-field>
</div>
</div>
</template>

<script>
import { ref } from 'vue'
export default {
setup () {
return {
divText: ref('div tag content'),
labelText: ref('label tag placeholder')
}
}
}
</script>
9 changes: 9 additions & 0 deletions docs/src/pages/vue-components/field.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ The `square` prop only makes sense along with Filled, Outlined and Standout desi

## Basic features

### Tag Wrapper
Allowing selection between `label` for form control fields and `div` for custom components with a `tag` property, enhances form functionality, and accessibility.

::: warning
If using `label`, ensure it is associated with form control fields and link the generated ID to the form field to avoid an accessibility violation.
:::

<DocExample title="Tag" file="TagWrapper" />

### Clearable
As a helper, you can use `clearable` prop so user can reset model to `null` through an appended icon.

Expand Down

0 comments on commit f3fdbd6

Please sign in to comment.