SInputRadios
<SInputRadios> is a radio button input component.
Usage
Import <SInputRadios> component and pass in :options and :value props.
<script setup lang="ts">
import { ref } from 'vue'
import SInputRadios from '@globalbrain/sefirot/lib/components/SInputRadios.vue'
const input = ref(1)
const options = [
{ label: 'Item 001', value: 1 },
{ label: 'Item 002', value: 2 },
{ label: 'Item 003', value: 3 }
]
</script>
<template>
<SInputRadios :options v-model="input" />
</template>Props
Here are the list of props you may pass to the component.
:size
Defines the size of the input. The default is 'small'.
interface Props {
size?: 'mini' | 'small' | 'medium'
}<SInputRadios
size="small"
:options="[...]"
v-model="input"
/>:label
Defines the label text of the input.
interface Props {
label?: string
}<SInputRadios
label="Name"
:options="[...]"
v-model="input"
/>:info
Shows help icon after the label and shows info in a tooltip when the user hovers the label.
interface Props {
info?: string
}<SInputRadios
label="Domain"
info="Some helpful information."
:options="[...]"
v-model="input"
/>:note
Adds small help text after the label. Best used along with :label.
interface Props {
note?: string
}<SInputRadios
label="Company URL"
note="Optional"
:options="[...]"
v-model="input"
/>:check-icon
Icon to display at corner right of label. Useful to show the status of a particular input.
interface Props {
checkIcon?: Component
}<SInputRadios :check-icon="IconCheckCircle" />:check-text
Text to display alongside :check-icon.
interface Props {
checkText?: string
}<SInputRadios :check-text="Saved" />:check-color
Defines the color of :check-icon and :check-text. The default is 'neutral'.
interface Props {
checkColor?: Color
}
type Color =
| 'neutral'
| 'mute'
| 'info'
| 'success'
| 'warning'
| 'danger'<SInputRadios
:check-icon="IconCheckCircle"
check-text="Uploaded"
check-color="success"
/>:options
The list of selectable options for the input.
interface Props {
options?: Option[]
}
export interface Option {
label: string
value: string | number | boolean
disabled?: boolean
}<SInputRadios
:options="[
{ label: 'Item 001', value: 1 },
{ label: 'Item 002', value: 2 },
{ label: 'Item 003', value: 3 }
]"
v-model="input"
/>:nullable
Enables the user to deselect options. The default is false.
interface Props {
nullable?: boolean
}<SInputRadios
:options="[...]"
nullable
v-model="input"
/>:disabled
Mark input as disabled. When this prop is set, users may not be able to focus the element nor trigger any events.
interface Props {
disabled?: boolean
}<SInputRadios
:options="[...]"
disabled
v-model="input"
/>:value
Sets the input value. When :model-value is set (e.g. via v-model directive), this prop is ignored.
interface Props {
value?: string | number | boolean | null
}<SInputRadios
:options="[...]"
:value="1"
/>:model-value
The v-model binding for the input.
interface Props {
modelValue?: string | number | boolean | null
}<SInputRadios
:options="[...]"
v-model="1"
/>:validation
The validation object for the input. It accepts Vuelidate like validation object and displays error if there're any.
import { Ref } from 'vue'
interface Props {
validation?: Validatable
}
export interface Validatable {
readonly $dirty: boolean
readonly $invalid: boolean
readonly $errors: ValidatableError[]
readonly $touch: () => void
}
export interface ValidatableError {
readonly $message: string | Ref<string>
}<SInputRadios
:options="[...]"
v-model="1"
:validation
/>:hide-error
Stop showing validation error message even when there are errors. This prop will not prevent the error color from appearing.
interface Props {
hideError?: boolean
}<SInputRadios
:options="[...]"
v-model="1"
:validation
hide-error
/>Slots
Here are the list of slots you may define within the component.
#info
Same as :info prop. When both :info and this slot are defined, this slot will take precedence.
<SInputRadios label="Domain" :options="[...]" v-model="input">
<template #info>
Learn more about this field <SLink href="...">here</SLink>.
</template>
</SInputRadios>Events
Here are the list of events the component may emit.
@update:model-value
Emits when the user selects the item. This event is always emitted together with the @change event.
interface Emits {
'update:model-value': [value: Value]
}
type Value = string | number | boolean | null@change
Emits when the user selects the item. This event is always emitted together with the @update:model-value event.
interface Emits {
change: [value: Value]
}
type Value = string | number | boolean | nullStyles
You may customize the styles by overriding --input prefixed CSS variables.
Global input styles
You may customize the various styles of the component via global input related CSS variables. Please refer to Styles: Input Styles page.