mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-25 09:20:36 +01:00
docs: improve forms usage with examples
This commit is contained in:
7
docs/components/content/examples/CheckboxExample.vue
Normal file
7
docs/components/content/examples/CheckboxExample.vue
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<script setup>
|
||||||
|
const selected = ref(false)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UCheckbox v-model="selected" name="notifications" label="Notifications" />
|
||||||
|
</template>
|
||||||
7
docs/components/content/examples/InputExample.vue
Normal file
7
docs/components/content/examples/InputExample.vue
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<script setup>
|
||||||
|
const value = ref('')
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UInput v-model="value" />
|
||||||
|
</template>
|
||||||
23
docs/components/content/examples/RadioExample.vue
Normal file
23
docs/components/content/examples/RadioExample.vue
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<script setup>
|
||||||
|
const methods = [{
|
||||||
|
name: 'email',
|
||||||
|
value: 'email',
|
||||||
|
label: 'Email'
|
||||||
|
}, {
|
||||||
|
name: 'sms',
|
||||||
|
value: 'sms',
|
||||||
|
label: 'Phone (SMS)'
|
||||||
|
}, {
|
||||||
|
name: 'push',
|
||||||
|
value: 'push',
|
||||||
|
label: 'Push notification'
|
||||||
|
}]
|
||||||
|
|
||||||
|
const selected = ref('sms')
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="space-y-1">
|
||||||
|
<URadio v-for="method of methods" :key="method.name" v-model="selected" v-bind="method" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
9
docs/components/content/examples/SelectExample.vue
Normal file
9
docs/components/content/examples/SelectExample.vue
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<script setup>
|
||||||
|
const countries = ['United States', 'Canada', 'Mexico']
|
||||||
|
|
||||||
|
const country = ref(countries[0])
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<USelect v-model="country" :options="countries" />
|
||||||
|
</template>
|
||||||
7
docs/components/content/examples/TextareaExample.vue
Normal file
7
docs/components/content/examples/TextareaExample.vue
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<script setup>
|
||||||
|
const value = ref('')
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UTextarea v-model="value" />
|
||||||
|
</template>
|
||||||
7
docs/components/content/examples/ToggleExample.vue
Normal file
7
docs/components/content/examples/ToggleExample.vue
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<script setup>
|
||||||
|
const selected = ref(false)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UToggle v-model="selected" />
|
||||||
|
</template>
|
||||||
@@ -5,11 +5,22 @@ description: Display an input field.
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
::component-card
|
Use a `v-model` to make the Input reactive.
|
||||||
---
|
|
||||||
baseProps:
|
::component-example
|
||||||
name: 'input'
|
#default
|
||||||
---
|
:input-example
|
||||||
|
|
||||||
|
#code
|
||||||
|
```vue
|
||||||
|
<script setup>
|
||||||
|
const value = ref('')
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UInput v-model="value" />
|
||||||
|
</template>
|
||||||
|
```
|
||||||
::
|
::
|
||||||
|
|
||||||
### Style
|
### Style
|
||||||
|
|||||||
@@ -5,11 +5,22 @@ description: Display a textarea field.
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
::component-card
|
Use a `v-model` to make the Textarea reactive.
|
||||||
---
|
|
||||||
baseProps:
|
::component-example
|
||||||
name: 'textarea'
|
#default
|
||||||
---
|
:textarea-example
|
||||||
|
|
||||||
|
#code
|
||||||
|
```vue
|
||||||
|
<script setup>
|
||||||
|
const value = ref('')
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UTextarea v-model="value" />
|
||||||
|
</template>
|
||||||
|
```
|
||||||
::
|
::
|
||||||
|
|
||||||
### Style
|
### Style
|
||||||
|
|||||||
@@ -7,19 +7,24 @@ description: Display a select field.
|
|||||||
|
|
||||||
The Select component is a wrapper around the native `<select>` HTML element. For more advanced use cases like searching or multiple selection, consider using the [SelectMenu](/forms/select-menu) component.
|
The Select component is a wrapper around the native `<select>` HTML element. For more advanced use cases like searching or multiple selection, consider using the [SelectMenu](/forms/select-menu) component.
|
||||||
|
|
||||||
::component-card
|
Use a `v-model` to make the Select reactive alongside the `options` prop to pass an array of strings or objects.
|
||||||
---
|
|
||||||
baseProps:
|
::component-example
|
||||||
name: 'select'
|
#default
|
||||||
modelValue: 'United States'
|
:select-example
|
||||||
props:
|
|
||||||
options:
|
#code
|
||||||
- 'United States'
|
```vue
|
||||||
- 'Canada'
|
<script setup>
|
||||||
- 'Mexico'
|
const countries = ['United States', 'Canada', 'Mexico']
|
||||||
excludedProps:
|
|
||||||
- options
|
const country = ref(countries[0])
|
||||||
---
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<USelect v-model="country" :options="countries" />
|
||||||
|
</template>
|
||||||
|
```
|
||||||
::
|
::
|
||||||
|
|
||||||
### Style
|
### Style
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ headlessui:
|
|||||||
|
|
||||||
The SelectMenu component renders by default a [Select](/forms/select) component and is based on the `ui.select` preset. You can use most of the Select props to configure the display if you don't want to override the default slot such as [color](/forms/select#style), [variant](/forms/select#style), [size](/forms/select#size), [placeholder](/forms/select#placeholder), [icon](/forms/select#icon), [disabled](/forms/select#disabled), etc.
|
The SelectMenu component renders by default a [Select](/forms/select) component and is based on the `ui.select` preset. You can use most of the Select props to configure the display if you don't want to override the default slot such as [color](/forms/select#style), [variant](/forms/select#style), [size](/forms/select#size), [placeholder](/forms/select#placeholder), [icon](/forms/select#icon), [disabled](/forms/select#disabled), etc.
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
Like the Select component, you can use the `options` prop to pass an array of strings or objects.
|
Like the Select component, you can use the `options` prop to pass an array of strings or objects.
|
||||||
|
|
||||||
::component-example
|
::component-example
|
||||||
|
|||||||
@@ -5,11 +5,22 @@ description: Display a checkbox field.
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
::component-card
|
Use a `v-model` to make the Checkbox reactive.
|
||||||
---
|
|
||||||
baseProps:
|
::component-example
|
||||||
name: 'checkbox'
|
#default
|
||||||
---
|
:checkbox-example
|
||||||
|
|
||||||
|
#code
|
||||||
|
```vue
|
||||||
|
<script setup>
|
||||||
|
const selected = ref(false)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UCheckbox v-model="selected" name="notifications" label="Notifications" />
|
||||||
|
</template>
|
||||||
|
```
|
||||||
::
|
::
|
||||||
|
|
||||||
### Label
|
### Label
|
||||||
|
|||||||
@@ -5,11 +5,36 @@ description: Display a radio field.
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
::component-card
|
Use a `v-model` to make the Radio reactive.
|
||||||
---
|
|
||||||
baseProps:
|
::component-example
|
||||||
name: 'radio'
|
#default
|
||||||
---
|
:radio-example
|
||||||
|
|
||||||
|
#code
|
||||||
|
```vue
|
||||||
|
<script setup>
|
||||||
|
const methods = [{
|
||||||
|
name: 'email',
|
||||||
|
value: 'email',
|
||||||
|
label: 'Email'
|
||||||
|
}, {
|
||||||
|
name: 'sms',
|
||||||
|
value: 'sms',
|
||||||
|
label: 'Phone (SMS)'
|
||||||
|
}, {
|
||||||
|
name: 'push',
|
||||||
|
value: 'push',
|
||||||
|
label: 'Push notification'
|
||||||
|
}]
|
||||||
|
|
||||||
|
const selected = ref('sms')
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<URadio v-for="method of methods" :key="method.name" v-model="selected" v-bind="method" />
|
||||||
|
</template>
|
||||||
|
```
|
||||||
::
|
::
|
||||||
|
|
||||||
### Label
|
### Label
|
||||||
|
|||||||
@@ -8,7 +8,22 @@ headlessui:
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
::component-card
|
Use a `v-model` to make the Toggle reactive.
|
||||||
|
|
||||||
|
::component-example
|
||||||
|
#default
|
||||||
|
:toggle-example
|
||||||
|
|
||||||
|
#code
|
||||||
|
```vue
|
||||||
|
<script setup>
|
||||||
|
const selected = ref(false)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UToggle v-model="selected" />
|
||||||
|
</template>
|
||||||
|
```
|
||||||
::
|
::
|
||||||
|
|
||||||
### Icon
|
### Icon
|
||||||
|
|||||||
Reference in New Issue
Block a user