mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-28 02:40:35 +01:00
docs: improve slots sections
This commit is contained in:
18
docs/components/content/examples/InputExampleClearable.vue
Normal file
18
docs/components/content/examples/InputExampleClearable.vue
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<template>
|
||||||
|
<UInput v-model="q" name="q" placeholder="Search..." icon="i-heroicons-magnifying-glass-20-solid" :ui="{ icon: { trailing: { pointer: '' } } }">
|
||||||
|
<template #trailing>
|
||||||
|
<UButton
|
||||||
|
v-show="q !== ''"
|
||||||
|
color="gray"
|
||||||
|
variant="link"
|
||||||
|
icon="i-heroicons-x-mark-20-solid"
|
||||||
|
:padded="false"
|
||||||
|
@click="q = ''"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</UInput>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const q = ref('')
|
||||||
|
</script>
|
||||||
@@ -275,6 +275,48 @@ code: |
|
|||||||
:u-button{icon="i-heroicons-chevron-down-20-solid" color="gray"}
|
:u-button{icon="i-heroicons-chevron-down-20-solid" color="gray"}
|
||||||
::
|
::
|
||||||
|
|
||||||
|
## Slots
|
||||||
|
|
||||||
|
### `leading`
|
||||||
|
|
||||||
|
Use the `#leading` slot to set the content of the leading icon.
|
||||||
|
|
||||||
|
::component-card
|
||||||
|
---
|
||||||
|
slots:
|
||||||
|
leading: <UAvatar src="https://avatars.githubusercontent.com/u/739984?v=4" size="3xs" />
|
||||||
|
baseProps:
|
||||||
|
color: 'gray'
|
||||||
|
props:
|
||||||
|
label: Button
|
||||||
|
color: 'gray'
|
||||||
|
excludedProps:
|
||||||
|
- color
|
||||||
|
---
|
||||||
|
|
||||||
|
#leading
|
||||||
|
:u-avatar{src="https://avatars.githubusercontent.com/u/739984?v=4" size="3xs"}
|
||||||
|
::
|
||||||
|
|
||||||
|
### `trailing`
|
||||||
|
|
||||||
|
Use the `#trailing` slot to set the content of the trailing icon.
|
||||||
|
|
||||||
|
::component-card
|
||||||
|
---
|
||||||
|
slots:
|
||||||
|
trailing: <UIcon name="i-heroicons-arrow-right-20-solid" />
|
||||||
|
props:
|
||||||
|
label: Button
|
||||||
|
color: 'gray'
|
||||||
|
excludedProps:
|
||||||
|
- color
|
||||||
|
---
|
||||||
|
|
||||||
|
#trailing
|
||||||
|
:u-icon{name="i-heroicons-arrow-right-20-solid"}
|
||||||
|
::
|
||||||
|
|
||||||
## Props
|
## Props
|
||||||
|
|
||||||
:component-props
|
:component-props
|
||||||
|
|||||||
@@ -142,6 +142,75 @@ excludedProps:
|
|||||||
---
|
---
|
||||||
::
|
::
|
||||||
|
|
||||||
|
## Slots
|
||||||
|
|
||||||
|
### `leading`
|
||||||
|
|
||||||
|
Use the `#leading` slot to set the content of the leading icon.
|
||||||
|
|
||||||
|
::component-card
|
||||||
|
---
|
||||||
|
slots:
|
||||||
|
leading: <UAvatar src="https://avatars.githubusercontent.com/u/739984?v=4" size="3xs" />
|
||||||
|
baseProps:
|
||||||
|
name: 'input'
|
||||||
|
placeholder: 'Search...'
|
||||||
|
---
|
||||||
|
|
||||||
|
#leading
|
||||||
|
:u-avatar{src="https://avatars.githubusercontent.com/u/739984?v=4" size="3xs"}
|
||||||
|
::
|
||||||
|
|
||||||
|
### `trailing`
|
||||||
|
|
||||||
|
Use the `#trailing` slot to set the content of the trailing icon.
|
||||||
|
|
||||||
|
::component-card
|
||||||
|
---
|
||||||
|
slots:
|
||||||
|
trailing: <span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span>
|
||||||
|
baseProps:
|
||||||
|
name: 'input'
|
||||||
|
placeholder: 'Search...'
|
||||||
|
---
|
||||||
|
|
||||||
|
#trailing
|
||||||
|
[EUR]{class="text-gray-500 dark:text-gray-400 text-xs"}
|
||||||
|
::
|
||||||
|
|
||||||
|
You can for example create a clearable Input by injecting a [Button](/elements/button) in the `trailing` slot that displays when some text is entered.
|
||||||
|
|
||||||
|
::component-example
|
||||||
|
#default
|
||||||
|
:input-example-clearable
|
||||||
|
|
||||||
|
#code
|
||||||
|
```vue
|
||||||
|
<template>
|
||||||
|
<UInput v-model="q" name="q" placeholder="Search..." icon="i-heroicons-magnifying-glass-20-solid" :ui="{ icon: { trailing: { pointer: '' } } }">
|
||||||
|
<template #trailing>
|
||||||
|
<UButton
|
||||||
|
v-show="q !== ''"
|
||||||
|
color="gray"
|
||||||
|
variant="link"
|
||||||
|
icon="i-heroicons-x-mark-20-solid"
|
||||||
|
:padded="false"
|
||||||
|
@click="q = ''"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</UInput>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const q = ref('')
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
::
|
||||||
|
|
||||||
|
::alert{icon="i-heroicons-exclamation-triangle-20-solid"}
|
||||||
|
As leading and trailing icons are wrapped around a `pointer-events-none` class, if you inject a clickable element in the slot, you need to remove this class to make it clickable by adding `:ui="{ icon: { trailing: { pointer: '' } } }"` to the Input.
|
||||||
|
::
|
||||||
|
|
||||||
## Props
|
## Props
|
||||||
|
|
||||||
:component-props
|
:component-props
|
||||||
|
|||||||
@@ -180,6 +180,46 @@ excludedProps:
|
|||||||
---
|
---
|
||||||
::
|
::
|
||||||
|
|
||||||
|
## Slots
|
||||||
|
|
||||||
|
### `leading`
|
||||||
|
|
||||||
|
Use the `#leading` slot to set the content of the leading icon.
|
||||||
|
|
||||||
|
::component-card
|
||||||
|
---
|
||||||
|
slots:
|
||||||
|
leading: <UAvatar src="https://avatars.githubusercontent.com/u/739984?v=4" size="3xs" />
|
||||||
|
baseProps:
|
||||||
|
name: 'select'
|
||||||
|
options:
|
||||||
|
- 'United States'
|
||||||
|
- 'Canada'
|
||||||
|
- 'Mexico'
|
||||||
|
placeholder: 'Search...'
|
||||||
|
---
|
||||||
|
|
||||||
|
#leading
|
||||||
|
:u-avatar{src="https://avatars.githubusercontent.com/u/739984?v=4" size="3xs"}
|
||||||
|
::
|
||||||
|
|
||||||
|
### `trailing`
|
||||||
|
|
||||||
|
Use the `#trailing` slot to set the content of the trailing icon.
|
||||||
|
|
||||||
|
::component-card
|
||||||
|
---
|
||||||
|
slots:
|
||||||
|
trailing: <UIcon name="i-heroicons-arrows-up-down-20-solid" />
|
||||||
|
baseProps:
|
||||||
|
name: 'input'
|
||||||
|
placeholder: 'Search...'
|
||||||
|
---
|
||||||
|
|
||||||
|
#trailing
|
||||||
|
:u-icon{name="i-heroicons-arrows-up-down-20-solid"}
|
||||||
|
::
|
||||||
|
|
||||||
## Props
|
## Props
|
||||||
|
|
||||||
:component-props
|
:component-props
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ props:
|
|||||||
|
|
||||||
## Slots
|
## Slots
|
||||||
|
|
||||||
### `#label`
|
### `label`
|
||||||
|
|
||||||
You can override the `#label` slot and handle the display yourself.
|
You can override the `#label` slot and handle the display yourself.
|
||||||
|
|
||||||
@@ -177,7 +177,7 @@ const selected = ref([])
|
|||||||
```
|
```
|
||||||
::
|
::
|
||||||
|
|
||||||
### `#default`
|
### `default`
|
||||||
|
|
||||||
You can also override the `#default` slot entirely.
|
You can also override the `#default` slot entirely.
|
||||||
|
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ excludedProps:
|
|||||||
|
|
||||||
You can use slots to customize the header and data cells of the table.
|
You can use slots to customize the header and data cells of the table.
|
||||||
|
|
||||||
### `#<column>-header`
|
### `<column>-header`
|
||||||
|
|
||||||
Use the `#<column>-header` slot to customize the header cell of a column. You will have access to the `column`, `sort` and `on-sort` properties in the slot scope.
|
Use the `#<column>-header` slot to customize the header cell of a column. You will have access to the `column`, `sort` and `on-sort` properties in the slot scope.
|
||||||
|
|
||||||
@@ -418,7 +418,7 @@ The `on-sort` property is a function that you can call to sort the table and acc
|
|||||||
Even though you can customize the sort button as mentioned in the [Sortable](#sortable) section, you can use this slot to completely override its behavior, with a custom dropdown for example.
|
Even though you can customize the sort button as mentioned in the [Sortable](#sortable) section, you can use this slot to completely override its behavior, with a custom dropdown for example.
|
||||||
::
|
::
|
||||||
|
|
||||||
### `#<column>-data`
|
### `<column>-data`
|
||||||
|
|
||||||
Use the `#<column>-data` slot to customize the data cell of a column. You will have access to the `row` and `column` properties in the slot scope.
|
Use the `#<column>-data` slot to customize the data cell of a column. You will have access to the `row` and `column` properties in the slot scope.
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,6 @@ description: Display a card for content with a header, body and footer.
|
|||||||
|
|
||||||
:component-props
|
:component-props
|
||||||
|
|
||||||
## Slots
|
|
||||||
|
|
||||||
:component-slots
|
|
||||||
|
|
||||||
## Preset
|
## Preset
|
||||||
|
|
||||||
:component-preset
|
:component-preset
|
||||||
|
|||||||
Reference in New Issue
Block a user