Skip to Content

API Reference

useViraMask

The primary hook for ViraStack Mask.

function useViraMask<TFieldValues, TSchema>( props: UseViraMaskProps<TFieldValues, TSchema> ): MaskFields<TSchema>

Props

PropTypeDescription
formUseFormReturn<TFieldValues>The object returned by RHF’s useForm.
schemaMaskSchema<TFieldValues>Configuration object mapping field names to masks.

Returns

Returns an object where each key matches the schema keys. Each value is a MaskField object.

MaskField

The object meant to be spread onto an <input> element.

interface MaskField { ref: RefCallback<HTMLInputElement>; name: string; value: string; // Display value (masked) rawValue: string; // Clean value (unmasked) onChange: (e: ChangeEvent) => void; onBlur: (e: FocusEvent) => void; onFocus: (e: FocusEvent) => void; type?: string; inputMode?: string; autoComplete?: string; 'aria-invalid'?: boolean; 'aria-describedby'?: string; title?: string; }

© 2026 ViraStack. MIT License.