BlogPlaygroundOne

VSwitch API


Props
name
type
default
  | string
  | (string | [string, number])[]
  | (new () => any)
  | FunctionalComponent
undefined

Creates a v-icon component after default content in the append slot.

string
undefined

Sets the color of the input when it is not focused.

boolean
true

Vertically align appendInner, prependInner, clearIcon and label in the center.

string
undefined

Applies specified color to the control - supports utility colors with or without text- prefix (for example success, purple or text-purple) or CSS color (#033 or rgba(255, 0, 0, 0.5)). Find a list of built-in classes on the colors page.

string
undefined

The target component to provide defaults values for.

'default' | 'comfortable' | 'compact'
'default'

Adjusts the vertical height used by the component.

'vertical' | 'horizontal'
'horizontal'

Changes the direction of the input.

boolean
null

Removes the ability to click or target the component.

boolean
false

Puts the input in a manual error state.

string | string[]
[]

Puts the input in an error state and passes through custom error messages. Will be combined with any validations that occur from the rules prop. This field will not trigger validation.

  | string
  | (string | [string, number])[]
  | (new () => any)
  | FunctionalComponent
undefined

The icon used when inactive.

any
undefined

Sets value for falsy state.

boolean
false

Display component without elevation. Default elevation for thumb is 4dp, flat resets it.

boolean
false

Forces a focused state styling on the component.

boolean
false

Makes prepend/append icons full opacity when the input is focused and apply color.

boolean | 'auto'
false

Hides hint and validation errors. When set to auto messages will be rendered only if there’s a message (hint, error message, counter value etc) to display.

boolean
false

Hides spin buttons on the input when type is set to number.

string
undefined

Displays hint text below the input when focused. Force this always open with the persistent-hint property.

string | boolean
false

Sets the color of the prepend/append icons.

string
undefined

Sets the DOM id on the component.

boolean
null

Adds / removes inline padding in inputs details. Useful when trying to align different variants of fields and selection controls.

boolean
false

Sets an indeterminate state for the switch.

boolean
false

Puts children inputs into a row.

boolean
false

Enlarge the v-switch track to encompass the thumb.

string
undefined

Sets the text of the v-label or v-field-label component.

string | boolean
false

Displays circular progress bar. Can either be a String which specifies which color is applied to the progress bar (any material color or theme color - primary, secondary, success, info, warning, error) or a Boolean which uses the component color (set by color prop - if it’s supported by the component) or the primary color.

string | number
1

Control the maximum number of shown errors from validation.

string | number
undefined

Sets the maximum width for the component.

string | string[]
[]

Displays a list of messages or a single message if using a string.

string | number
undefined

Sets the minimum width for the component.

unknown
undefined

The v-model value of the component. If component supports the multiple prop, this defaults to an empty array.

boolean
null

Changes expected model to an array.

string
undefined

Sets the component’s name attribute.

boolean
false

Forces hint to always be visible.

  | string
  | (string | [string, number])[]
  | (new () => any)
  | FunctionalComponent
undefined

Prepends an icon to the component, uses the same syntax as v-icon.

boolean
null

Puts input in readonly state.

boolean | { class: string; keys: string[] }
true

Applies the v-ripple directive.

(
  | string
  | boolean
  | PromiseLike<ValidationResult>
  | ((value: any) => string | false | true)
  | ((value: any) => PromiseLike<ValidationResult>)
  | [string, any, string]
)[]
[]

Accepts a mixed array of types function, boolean and string. Functions pass an input value as an argument and must return either true / false or a string containing an error message. The input field will enter an error state if a function returns (or any value in the array contains) false or is a string.

string
undefined

Specify a theme for this component and all of its children.

  | string
  | (string | [string, number])[]
  | (new () => any)
  | FunctionalComponent
undefined

The icon used when active.

any
undefined

Sets value for truthy state.

string
undefined

Provides the default type for children selection controls.

  | 'eager'
  | 'lazy'
  | 'blur'
  | 'input'
  | 'submit'
  | 'invalid-input'
  | 'blur lazy'
  | 'input lazy'
  | 'submit lazy'
  | 'invalid-input lazy'
  | 'blur eager'
  | 'input eager'
  | 'submit eager'
  | 'invalid-input eager'
  | 'lazy blur'
  | 'lazy input'
  | 'lazy submit'
  | 'lazy invalid-input'
  | 'eager blur'
  | 'eager input'
  | 'eager submit'
  | 'eager invalid-input'
undefined

Change what type of event triggers validation to run.

any
undefined

The value used when applying validation rules.

any
undefined

The value used when the component is selected in a group. If not provided, a unique ID will be used.

(a: any, b: any) => boolean
undefined

Apply a custom comparison algorithm to compare model-value and values contains in the items prop.

string | number
undefined

Sets the width for the component.

Events
name
type
[MouseEvent]

Emitted when appended icon is clicked.

[MouseEvent]

Emitted when prepended icon is clicked.

[boolean]

Event that is emitted when the component’s focus state changes.

[boolean]

Event that is emitted when the component’s indeterminate state changes.

[unknown]

Event that is emitted when the component’s model changes.

Slots
{ id: ComputedRef<string> messagesId: ComputedRef<string | undefined> isDirty: ComputedRef<boolean> isDisabled: ComputedRef<boolean> isReadonly: ComputedRef<boolean> isPristine: Ref<boolean, boolean> isValid: ComputedRef<boolean | null> isValidating: Ref<boolean, boolean> hasDetails: Ref<boolean, boolean> reset: () => void resetValidation: () => void validate: () => void }
{ id: ComputedRef<string> messagesId: ComputedRef<string | undefined> isDirty: ComputedRef<boolean> isDisabled: ComputedRef<boolean> isReadonly: ComputedRef<boolean> isPristine: Ref<boolean, boolean> isValid: ComputedRef<boolean | null> isValidating: Ref<boolean, boolean> hasDetails: Ref<boolean, boolean> reset: () => void resetValidation: () => void validate: () => void } & { backgroundColorClasses: Ref<string[], string[]> backgroundColorStyles: Ref<CSSProperties, CSSProperties> }
{ id: ComputedRef<string> messagesId: ComputedRef<string | undefined> isDirty: ComputedRef<boolean> isDisabled: ComputedRef<boolean> isReadonly: ComputedRef<boolean> isPristine: Ref<boolean, boolean> isValid: ComputedRef<boolean | null> isValidating: Ref<boolean, boolean> hasDetails: Ref<boolean, boolean> reset: () => void resetValidation: () => void validate: () => void }
{ model: WritableComputedRef<boolean, boolean> textColorClasses: Ref<string[], string[]> textColorStyles: Ref<CSSProperties, CSSProperties> backgroundColorClasses: Ref<string[], string[]> backgroundColorStyles: Ref<CSSProperties, CSSProperties> inputNode: VNode<RendererNode, RendererElement, { [key: string]: any }> icon: | string | (string | [string, number])[] | (new () => any) | FunctionalComponent props: { onBlur: (e: Event) => void onFocus: (e: FocusEvent) => void id: string } }
{ label: string; props: Record<string, unknown> }
{ color: string; isActive: boolean }
{ message: string }
{ id: ComputedRef<string> messagesId: ComputedRef<string | undefined> isDirty: ComputedRef<boolean> isDisabled: ComputedRef<boolean> isReadonly: ComputedRef<boolean> isPristine: Ref<boolean, boolean> isValid: ComputedRef<boolean | null> isValidating: Ref<boolean, boolean> hasDetails: Ref<boolean, boolean> reset: () => void resetValidation: () => void validate: () => void }
{ icon: | string | (string | [string, number])[] | (new () => any) | FunctionalComponent } & { model: Ref<boolean, boolean>; isValid: ComputedRef<boolean | null> }
{ model: Ref<boolean, boolean> isValid: ComputedRef<boolean | null> }
{ model: Ref<boolean, boolean> isValid: ComputedRef<boolean | null> }

Adds an item inside the input and after input content.

The default Vue slot.

Slot for custom input details to modifying the display of messages.

The slot used for the default input element.

The default slot of the v-label or v-field-label component.

Slot for custom loader (displayed when loading prop is equal to true).

Slot used to customize the message content.

Adds an item outside the input and before input content.

Slot for custom thumb content.

Slot for custom track content when value is false.

Slot for custom track content when value is true.

Exposed
string[]
boolean
() => Promise<void>
() => Promise<void>
(silent: boolean) => Promise<string[]>

An array of error messages that were set by the setErrors method.

Boolean indicating if the input is valid.

Resets the input value.

Resets validation of the input without modifying its value.

Validates the input’s value.

SASS Variables
name
default
.2s transform settings.$standard-easing
rgb(var(--v-theme-error))
rgb(var(--v-theme-on-error))
0 1 auto
24px
16px
16px
24px
9999px
32px
52px
10px
rgb(var(--v-theme-surface))
rgb(var(--v-theme-surface-bright))
rgb(var(--v-theme-on-surface-bright))
2
rgb(var(--v-theme-surface-variant))
rgb(var(--v-theme-on-surface-variant))
20px
2px
50%
.15s .05s transform settings.$decelerated-easing, .2s color settings.$standard-easing, .2s background-color settings.$standard-easing
rotate(-90deg)
20px
rgb(var(--v-theme-surface-variant))
14px
.6
9999px
.2s background-color settings.$standard-easing
36px