2024-12-04 15:06:34 +00:00
|
|
|
<script setup>
|
|
|
|
import Input from "~/components/ui/Input.vue"
|
2024-12-29 16:18:46 +00:00
|
|
|
import Button from "~/components/ui/Button.vue"
|
|
|
|
import Layout from "~/components/ui/Layout.vue"
|
|
|
|
import Spacer from "~/components/ui/layout/Spacer.vue"
|
2024-12-30 10:50:57 +00:00
|
|
|
import Alert from "~/components/ui/Alert.vue"
|
2024-12-04 15:06:34 +00:00
|
|
|
</script>
|
|
|
|
|
2024-11-26 11:59:11 +00:00
|
|
|
# Input
|
|
|
|
|
|
|
|
Inputs are areas in which users can enter information. In Funkwhale, these mostly take the form of search fields.
|
|
|
|
|
2024-12-15 14:06:27 +00:00
|
|
|
| Prop | Data type | Required? | Description |
|
|
|
|
| --------------- | --------- | --------- | --------------------------------------------------------------------------- |
|
|
|
|
| `placeholder` | String | No | The placeholder text that appears when the input is empty. |
|
|
|
|
| `icon` | String | No | The [Bootstrap icon](https://icons.getbootstrap.com/) to show on the input. |
|
|
|
|
| `v-model:value` | String | Yes | The text entered in the input. |
|
2024-11-26 11:59:11 +00:00
|
|
|
|
|
|
|
## Input model
|
|
|
|
|
|
|
|
You can link a user's input to form data by referencing the data in a `v-model` directive.
|
|
|
|
|
|
|
|
```vue-html{2}
|
2024-12-04 15:06:34 +00:00
|
|
|
<Input v-model="value" placeholder="Search" />
|
2024-11-26 11:59:11 +00:00
|
|
|
```
|
|
|
|
|
2024-12-04 15:06:34 +00:00
|
|
|
<Input placeholder="Search" />
|
2024-11-26 11:59:11 +00:00
|
|
|
|
|
|
|
## Input icons
|
|
|
|
|
|
|
|
Add a [Bootstrap icon](https://icons.getbootstrap.com/) to an input to make its purpose more visually clear.
|
|
|
|
|
|
|
|
```vue-html{3}
|
2024-12-04 15:06:34 +00:00
|
|
|
<Input v-model="value" icon="bi-search" placeholder="Search" />
|
2024-11-26 11:59:11 +00:00
|
|
|
```
|
|
|
|
|
2024-12-04 15:06:34 +00:00
|
|
|
<Input icon="bi-search" placeholder="Search" />
|
2024-11-26 11:59:11 +00:00
|
|
|
|
2024-12-29 17:04:32 +00:00
|
|
|
## Label slot
|
|
|
|
|
|
|
|
```vue-html{2-4}
|
|
|
|
<Input>
|
|
|
|
<template #label>
|
|
|
|
User name
|
|
|
|
</template>
|
|
|
|
</Input>
|
|
|
|
```
|
|
|
|
|
|
|
|
<Input>
|
|
|
|
<template #label>
|
|
|
|
User name
|
|
|
|
</template>
|
|
|
|
</Input>
|
|
|
|
|
|
|
|
If you just have a string, we have a convenience prop, so instead you can write:
|
|
|
|
|
|
|
|
```vue-html
|
|
|
|
<Input label="User name" />
|
|
|
|
```
|
|
|
|
|
|
|
|
<Input label="User name" />
|
|
|
|
|
2024-11-26 11:59:11 +00:00
|
|
|
## Input-right slot
|
|
|
|
|
|
|
|
You can add a template on the right-hand side of the input to guide the user's input.
|
|
|
|
|
|
|
|
```vue-html{2-4}
|
2024-12-04 15:06:34 +00:00
|
|
|
<Input v-model="value" placeholder="Search">
|
2024-11-26 11:59:11 +00:00
|
|
|
<template #input-right>
|
|
|
|
suffix
|
|
|
|
</template>
|
2024-12-04 15:06:34 +00:00
|
|
|
</Input>
|
2024-11-26 11:59:11 +00:00
|
|
|
```
|
|
|
|
|
2024-12-04 15:06:34 +00:00
|
|
|
<Input placeholder="Search">
|
2024-11-26 11:59:11 +00:00
|
|
|
<template #input-right>
|
|
|
|
suffix
|
|
|
|
</template>
|
2024-12-04 15:06:34 +00:00
|
|
|
</Input>
|
2024-12-29 16:18:46 +00:00
|
|
|
|
|
|
|
## Presets
|
|
|
|
|
|
|
|
### Search
|
|
|
|
|
2024-12-29 16:52:02 +00:00
|
|
|
```vue-html
|
|
|
|
<Input search />
|
|
|
|
```
|
|
|
|
|
2024-12-29 16:18:46 +00:00
|
|
|
<Input search />
|
|
|
|
|
|
|
|
### Password
|
|
|
|
|
2024-12-29 16:52:02 +00:00
|
|
|
```vue-html
|
2024-12-30 10:50:57 +00:00
|
|
|
<Spacer :size="64" />
|
|
|
|
<Layout form stack>
|
|
|
|
<Input label="User name" />
|
|
|
|
<Input password label="Password" />
|
|
|
|
<Layout flex>
|
|
|
|
<Button primary> Submit </Button>
|
|
|
|
<Button> Cancel </Button>
|
|
|
|
</Layout>
|
2024-12-29 16:18:46 +00:00
|
|
|
</Layout>
|
2024-12-29 16:52:02 +00:00
|
|
|
```
|
|
|
|
|
2024-12-30 10:50:57 +00:00
|
|
|
<Spacer :size="64" />
|
|
|
|
<Layout form stack>
|
|
|
|
<Input label="User name" />
|
|
|
|
<Input password label="Password" />
|
|
|
|
<Layout flex>
|
|
|
|
<Button primary> Submit </Button>
|
|
|
|
<Button> Cancel </Button>
|
|
|
|
</Layout>
|
2024-12-29 16:52:02 +00:00
|
|
|
</Layout>
|
|
|
|
|
2024-12-30 10:50:57 +00:00
|
|
|
::: tip
|
|
|
|
|
|
|
|
We use the spacer to simulate the baseline alignment on page layouts (64px between sections)
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
2024-12-29 16:52:02 +00:00
|
|
|
## Fallthrough attributes
|
|
|
|
|
|
|
|
If you add attributes that are no props, they will be added to the component:
|
|
|
|
|
|
|
|
```vue-html
|
|
|
|
<Input required
|
|
|
|
field-id="password-field"
|
|
|
|
/>
|
|
|
|
```
|
|
|
|
|
|
|
|
<Input required
|
|
|
|
field-id="password-field"
|
|
|
|
/>
|