Input
Default classes
Base Input (wrapper of Virgo Input)
import type { ComponentClasses } from '@/plugin'
import type { baseInputProps } from '@/components/base-input/meta'
export const baseInputClasses: ComponentClasses<baseInputProps> = {
root: ({ disabled, readonly }) => {
return [
'virgo-base-input-root i:children:focus-within:text-primary flex flex-col flex-grow flex-shrink-0 gap-y-1',
{
'!all-[.virgo-base-input-input-wrapper]-bg-[hsla(var(--virgo-base-c),0.12)] opacity-50': disabled,
'pointer-events-none': disabled || readonly,
'all-[.virgo-base-input-child]-placeholder:transition all-[.virgo-base-input-child]-placeholder:duration-250 all-[.virgo-base-input-child]-placeholder:ease all-[.virgo-base-input-child:focus]-placeholder-translate-x-1': !(disabled || readonly)
}
]
},
label: ({ error }) => {
return [
'virgo-base-input-label',
{
'text-red-500': error
}
]
},
inputContainer: 'virgo-base-input-input-container flex items-center i:w-6 i:h-6 gap-x-3',
inputWrapper: ({ error }) => {
return [
'virgo-base-input-input-wrapper transition duration-250 ease-out flex i:w-5 i:h-5 [&_>_.virgo-spinner]-w-5 h-10 rounded-lg cursor-text px-4 spacing:gap-x-2 relative i:focus-within:text-primary items-center border border-solid border-a-border w-full',
error ? 'border-red-500' : 'focus-within:border-purple-500'
]
},
inputChild: ({ slots, prependInnerIcon, appendInnerIcon }) => {
return [
'virgo-base-input-child w-full h-full inset-0 rounded-inherit bg-transparent',
slots?.['prepend-inner'] || prependInnerIcon
? 'has-prepend-inner'
: 'has-no-prepend-inner',
slots?.['append-inner'] || appendInnerIcon
? 'has-append-inner'
: 'has-no-append-inner'
]
},
messageContainer: 'h-8',
message: ({ error }) => error ? 'text-red-500' : 'text-light-emphasis',
icons: 'transition duration-150 ease-in',
prependIcon: '',
appendIcon: '',
prependInnerIcon: 'z-1',
appendInnerIcon: 'ms-auto'
}
export type baseInputClassesValidKeys = keyof typeof baseInputClassesimport type { ComponentClasses } from '@/plugin'
import type { baseInputProps } from '@/components/base-input/meta'
export const baseInputClasses: ComponentClasses<baseInputProps> = {
root: ({ disabled, readonly }) => {
return [
'virgo-base-input-root i:children:focus-within:text-primary flex flex-col flex-grow flex-shrink-0 gap-y-1',
{
'!all-[.virgo-base-input-input-wrapper]-bg-[hsla(var(--virgo-base-c),0.12)] opacity-50': disabled,
'pointer-events-none': disabled || readonly,
'all-[.virgo-base-input-child]-placeholder:transition all-[.virgo-base-input-child]-placeholder:duration-250 all-[.virgo-base-input-child]-placeholder:ease all-[.virgo-base-input-child:focus]-placeholder-translate-x-1': !(disabled || readonly)
}
]
},
label: ({ error }) => {
return [
'virgo-base-input-label',
{
'text-red-500': error
}
]
},
inputContainer: 'virgo-base-input-input-container flex items-center i:w-6 i:h-6 gap-x-3',
inputWrapper: ({ error }) => {
return [
'virgo-base-input-input-wrapper transition duration-250 ease-out flex i:w-5 i:h-5 [&_>_.virgo-spinner]-w-5 h-10 rounded-lg cursor-text px-4 spacing:gap-x-2 relative i:focus-within:text-primary items-center border border-solid border-a-border w-full',
error ? 'border-red-500' : 'focus-within:border-purple-500'
]
},
inputChild: ({ slots, prependInnerIcon, appendInnerIcon }) => {
return [
'virgo-base-input-child w-full h-full inset-0 rounded-inherit bg-transparent',
slots?.['prepend-inner'] || prependInnerIcon
? 'has-prepend-inner'
: 'has-no-prepend-inner',
slots?.['append-inner'] || appendInnerIcon
? 'has-append-inner'
: 'has-no-append-inner'
]
},
messageContainer: 'h-8',
message: ({ error }) => error ? 'text-red-500' : 'text-light-emphasis',
icons: 'transition duration-150 ease-in',
prependIcon: '',
appendIcon: '',
prependInnerIcon: 'z-1',
appendInnerIcon: 'ms-auto'
}
export type baseInputClassesValidKeys = keyof typeof baseInputClassesVirgo Input
import type { ComponentClasses } from '@/plugin'
import type { virgoInputProps } from '@/components/input/meta'
export const virgoInputClasses: ComponentClasses<virgoInputProps> = {
baseInputRoot: 'virgo-input-root',
fileType: 'file:[&_.virgo-base-input-child]-rounded-lg file:[&_.virgo-base-input-child]-border-none file:[&_.virgo-base-input-child]-mr-4 file:[&_.virgo-base-input-child]-px-4 file:[&_.virgo-base-input-child]-py-3 file:[&_.virgo-base-input-child]-text-gray-200 file:[&_.virgo-base-input-child]-rounded-r-none file:[&_.virgo-base-input-child]-bg-purple-500/05] !all-[.virgo-base-input-input-wrapper]-px-0',
input: 'virgo-input-input'
}
export type virgoInputClassesValidKeys = keyof typeof virgoInputClassesimport type { ComponentClasses } from '@/plugin'
import type { virgoInputProps } from '@/components/input/meta'
export const virgoInputClasses: ComponentClasses<virgoInputProps> = {
baseInputRoot: 'virgo-input-root',
fileType: 'file:[&_.virgo-base-input-child]-rounded-lg file:[&_.virgo-base-input-child]-border-none file:[&_.virgo-base-input-child]-mr-4 file:[&_.virgo-base-input-child]-px-4 file:[&_.virgo-base-input-child]-py-3 file:[&_.virgo-base-input-child]-text-gray-200 file:[&_.virgo-base-input-child]-rounded-r-none file:[&_.virgo-base-input-child]-bg-purple-500/05] !all-[.virgo-base-input-input-wrapper]-px-0',
input: 'virgo-input-input'
}
export type virgoInputClassesValidKeys = keyof typeof virgoInputClassesBasic
You can use virgo-input component to render basic input.
Placeholder
You can use placeholder attribute to add placeholder to the input.
Label
You can use label prop to add label to the input.
For maximum flexibility you can use label slot.
WARNING
When you use label slot, Note that label's for attribute needs to prefix the virgo-input- when binding it to input's id attribute.
TIP
virgo-input built on top of base-input base component. Hence, This demo also applies to all other inherited component.
Hint
You can use hint prop to add hint to the input.
Icons
You can use various icon location prop to add icon to the input.
Types
You can use type attribute to add input type.
States
You can use readonly prop to make input read only.
Use disabled prop to make input disabled.
Validation
Virgo do not provide any validation mechanism at the moment as it assume it's better handled by third-party libraries like VeeValidate
API
Set component in disabled state
Set component in readonly mode
Set loading state
Useful when used in the component config classes option, to style it conditionally. Can be a string, object, or an array of string or/and object.
Disable class inheritance from the Virgo plugin classes config. Only for this component.
Input wrapper attributes
Add hint below the form component
Error text to render. This will replace hint text if provided.
Label of the form component
Prepend icon
Append icon
Prepend icon inside input
Append icon inside input