Input ​
Usage ​
Use the v-model
directive to control the value of the Input.
Details
<script setup lang="ts">
import { ref } from 'vue'
const value = ref('')
</script>
<template>
<B24Input v-model="value" />
</template>
Type ​
Use the type
prop to change the input type. Defaults to text
.
Some types have been implemented in their own components such as Checkbox, Radio etc. and others have been styled like file
for example.
Details
<script setup lang="ts">
export interface ExampleProps {
type?: any
}
withDefaults(defineProps<ExampleProps>(), {
type: 'file'
})
</script>
<template>
<B24Input
:type="type"
/>
</template>
INFO
You can check all the available types on the MDN Web Docs.
Placeholder ​
Use the placeholder
prop to set a placeholder text.
Details
<script setup lang="ts">
export interface ExampleProps {
placeholder?: string
}
withDefaults(defineProps<ExampleProps>(), {
placeholder: 'Search...'
})
</script>
<template>
<B24Input
:placeholder="placeholder"
/>
</template>
Color ​
Use the color
prop to change the ring color when the Input is focused.
INFO
The highlight
prop is used here to show the focus state. It's used internally when a validation error occurs.
Details
<script setup lang="ts">
import type { InputProps } from '@bitrix24/b24ui-nuxt'
export interface ExampleProps {
color?: InputProps['color']
isHighlight?: boolean
}
withDefaults(defineProps<ExampleProps>(), {
color: 'default',
isHighlight: true
})
</script>
<template>
<B24Input
:color="color"
:highlight="isHighlight"
placeholder="Search..."
/>
</template>
Tag ​
Use the tag
property to display a small legend on top of the Input.
Use the tagColor
property to set the color for tag
.
Details
<script setup lang="ts">
import type { InputProps } from '@bitrix24/b24ui-nuxt'
export interface ExampleProps {
tagColor: InputProps['tagColor']
tag?: string
}
withDefaults(defineProps<ExampleProps>(), {
tagColor: 'default',
tag: 'info'
})
</script>
<template>
<B24Input
:tag-color="tagColor"
:tag="tag"
placeholder="Search..."
/>
</template>
Size ​
Use the size
prop to change the size of the Input.
Size ​
Use the size
prop to change the size of the Switch.
Details
<script setup lang="ts">
import type { InputProps } from '@bitrix24/b24ui-nuxt'
export interface ExampleProps {
size?: InputProps['size']
}
withDefaults(defineProps<ExampleProps>(), {
size: 'md' as const
})
</script>
<template>
<B24Input
:size="size"
placeholder="Search..."
/>
</template>
Icon ​
Use the icon
prop to show an @bitrix24/b24icons inside the Input.
Details
<script setup lang="ts">
import CrmSearchIcon from '@bitrix24/b24icons-vue/crm/CrmSearchIcon'
</script>
<template>
<B24Input
:icon="CrmSearchIcon"
placeholder="Search..."
/>
</template>
Use the leading-icon
and trailing-icon
props to set a different icon for each position.
Details
<script setup lang="ts">
import TaskIcon from '@bitrix24/b24icons-vue/button/TaskIcon'
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'
</script>
<template>
<B24Input
:icon="RocketIcon"
:trailing-icon="TaskIcon"
placeholder="Search..."
/>
</template>
Avatar ​
Use the avatar
prop to show an Avatar inside the Input.
Details
<script setup lang="ts">
import Bitrix24Icon from '@bitrix24/b24icons-vue/common-service/Bitrix24Icon'
</script>
<template>
<B24Input
:avatar="{ src: '/b24ui/avatar/employee.png' }"
placeholder="Search..."
/>
<B24Input
:avatar="{ icon: Bitrix24Icon }"
placeholder="Search..."
/>
</template>
Loading ​
Use the loading
prop to show a loading icon on the Input.
Details
<script setup lang="ts">
export interface ExampleProps {
isLoading?: boolean
}
withDefaults(defineProps<ExampleProps>(), {
isLoading: true
})
</script>
<template>
<B24Input
placeholder="Search..."
:loading="isLoading"
/>
</template>
Disabled ​
Use the disabled
prop to disable the Input.
Details
<script setup lang="ts">
export interface ExampleProps {
isDisabled?: boolean
}
withDefaults(defineProps<ExampleProps>(), {
isDisabled: true
})
</script>
<template>
<B24Input
placeholder="Search..."
:disabled="isDisabled"
/>
</template>
API ​
Props ​
Prop | Default | Type |
---|---|---|
as | 'div' | any The element or component this component should render as. |
modelValue | string | number | |
id | string | |
name | string | |
type | "text" | "number" | "reset" | "submit" | "image" | "color" | "text" | "button" | "date" | "time" | string & {} | "search" | "checkbox" | "file" | "datetime-local" | "email" | "hidden" | "month" | "password" | "radio" | "range" | "tel" | "url" | "week" |
placeholder | string The placeholder text when the input is empty. | |
color | "default" | "danger" | "success" | "warning" | "primary" | "secondary" | "collab" | "ai" | |
size | "lg" | "md" | "xs" | "sm" | |
noPadding | boolean Removes padding from input. | |
noBorder | boolean removes all borders (rings). | |
underline | boolean removes all borders (rings) except the bottom one. | |
rounded | boolean Rounds the corners of the button. | |
required | boolean | |
autocomplete | "off" | string |
autofocus | boolean | |
autofocusDelay | 0 | number |
disabled | boolean | |
tag | string | |
tagColor | "default" | "danger" | "success" | "warning" | "primary" | "secondary" | "collab" | "ai" | |
highlight | boolean Highlight the ring color like a focus state. | |
b24ui | PartialString<{ root: string; base: string; leading: string; leadingIcon: string; leadingAvatar: string; leadingAvatarSize: string; trailing: string; trailingIcon: string; tag: string; }> | |
icon | (props: HTMLAttributes & VNodeProps & {}, ctx: Omit<{ attrs: Data; slots: Readonly<InternalSlots>; emit: (event: string, ...args: any[]) => void; expose: <Exposed extends Record<string, any> = Record<...>>(exposed?: Exposed) => void; }, "expose">): any Display an icon on the left side. | |
avatar | AvatarProps Display an avatar on the left side. | |
loading | boolean When `true`, the loading icon will be displayed. | |
trailing | boolean When `true`, the icon will be displayed on the right side. | |
trailingIcon | (props: HTMLAttributes & VNodeProps & {}, ctx: Omit<{ attrs: Data; slots: Readonly<InternalSlots>; emit: (event: string, ...args: any[]) => void; expose: <Exposed extends Record<string, any> = Record<...>>(exposed?: Exposed) => void; }, "expose">): any Display an icon on the right side. |
Slots ​
Slot | Type |
---|---|
leading | {} |
default | {} |
trailing | {} |
Emits ​
Event | Type |
---|
Expose ​
When accessing the component via a template ref, you can use the following:
Name | Type |
---|---|
inputRef | Ref<HTMLInputElement | null> |