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: 'virgo-base-input-root i:children:focus-within:text-primary flex flex-col flex-grow flex-shrink-0 gap-y-1',
inputContainer: 'virgo-base-input-input-container flex items-center i:w-6 i:h-6 gap-x-3',
inputWrapper: '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',
inputWrapperError: 'border-danger',
inputWrapperValid: 'focus-within:border-primary',
prependInnerIcon: 'z-1',
appendInnerIcon: 'ms-auto',
disabledOrReadonly: 'pointer-events-none',
disabled: '!all-[.virgo-base-input-input-wrapper]-bg-[hsla(var(--virgo-base-c),0.12)] opacity-50',
interactive: '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',
label: 'virgo-base-input-label',
labelError: 'text-danger',
inputChild: 'virgo-base-input-child w-full h-full inset-0 rounded-inherit bg-transparent',
inputChildWithPrependInner: '',
inputChildWithAppendInner: '',
inputChildWithoutPrependInner: '',
inputChildWithoutAppendInner: '',
messageContainer: 'h-8', // hint and errors
messageError: 'text-danger',
messageHint: 'text-light-emphasis'
}
export type baseInputClassesValidKeys = keyof typeof baseInputClasses
import type { ComponentClasses } from '@/plugin'
import type { baseInputProps } from '@/components/base-input/meta'
export const baseInputClasses: ComponentClasses<baseInputProps> = {
root: 'virgo-base-input-root i:children:focus-within:text-primary flex flex-col flex-grow flex-shrink-0 gap-y-1',
inputContainer: 'virgo-base-input-input-container flex items-center i:w-6 i:h-6 gap-x-3',
inputWrapper: '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',
inputWrapperError: 'border-danger',
inputWrapperValid: 'focus-within:border-primary',
prependInnerIcon: 'z-1',
appendInnerIcon: 'ms-auto',
disabledOrReadonly: 'pointer-events-none',
disabled: '!all-[.virgo-base-input-input-wrapper]-bg-[hsla(var(--virgo-base-c),0.12)] opacity-50',
interactive: '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',
label: 'virgo-base-input-label',
labelError: 'text-danger',
inputChild: 'virgo-base-input-child w-full h-full inset-0 rounded-inherit bg-transparent',
inputChildWithPrependInner: '',
inputChildWithAppendInner: '',
inputChildWithoutPrependInner: '',
inputChildWithoutAppendInner: '',
messageContainer: 'h-8', // hint and errors
messageError: 'text-danger',
messageHint: 'text-light-emphasis'
}
export type baseInputClassesValidKeys = keyof typeof baseInputClasses
Virgo Input
import type { ComponentClasses } from '@/plugin'
import type { virgoInputProps } from '@/components/input/meta'
export const virgoInputClasses:ComponentClasses<virgoInputProps> = {
root: '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-500 file:[&_.virgo-base-input-child]-rounded-r-none file:[&_.virgo-base-input-child]-bg-[hsla(var(--virgo-base-color),0.05)] !all-[.virgo-base-input-input-wrapper]-px-0',
input: 'virgo-input-input',
}
export type virgoInputClassesValidKeys = keyof typeof virgoInputClasses
import type { ComponentClasses } from '@/plugin'
import type { virgoInputProps } from '@/components/input/meta'
export const virgoInputClasses:ComponentClasses<virgoInputProps> = {
root: '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-500 file:[&_.virgo-base-input-child]-rounded-r-none file:[&_.virgo-base-input-child]-bg-[hsla(var(--virgo-base-color),0.05)] !all-[.virgo-base-input-input-wrapper]-px-0',
input: 'virgo-input-input',
}
export type virgoInputClassesValidKeys = keyof typeof virgoInputClasses
Basic
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