Toggle
Toggles are boolean form components used for easily enabling or disabling features.
Basic Usage
<i-toggle v-model="toggled"></i-toggle>
export default {
data () {
return {
toggled: false
};
}
}
false
Sizes
You're able to use the size
property to control the size of your inputs, using one of the available sizes: sm
, md
, and lg
. The default size is set to md
.
<i-toggle size="sm" v-model="toggled"></i-toggle>
<i-toggle size="md" v-model="toggled"></i-toggle>
<i-toggle size="lg" v-model="toggled"></i-toggle>
export default {
data () {
return {
toggled: false
};
}
}
Applying the size size
property to an i-form-group
will also set the chosen size to all of its i-toggle
inputs.
Readonly State
You can set the toggle input to be readonly by using the readonly
property.
<i-toggle v-model="toggledFalse" readonly></i-toggle>
<i-toggle v-model="toggledTrue" readonly></i-toggle>
export default {
data () {
return {
toggledFalse: false,
toggledTrue: true
};
}
}
Disabled State
You can set the toggle input to be disabled by using the disabled
property.
<i-toggle v-model="toggledFalse" readonly></i-toggle>
<i-toggle v-model="toggledTrue" readonly></i-toggle>
export default {
data () {
return {
toggledFalse: false,
toggledTrue: true
};
}
}
Component API
Here you can find a list of the various customization options you can use for the toggle component as props, as well as available slots and events.
Boolean
true
, false
false
Boolean
true
, false
false
Object
String
sm
, md
, lg
md
Boolean
v-model
directive when the toggle input isn't grouped.String
light
, dark
light
(event: Event) => {}
(event: Event) => {}
(event: Event) => {}
(value: Boolean | String) => {}
Sass Variables
Here you can find a list of the Sass variables you can use for the toggle component. If you're looking to find common variables that these rely on, you should take a look at the Sass Variables page.
40px
size-map($toggle-width-base, $sizes, $size-multipliers)
20px
size-map($toggle-height-base, $sizes, $size-multipliers)
$toggle-height-base
size-map($toggle-border-radius-base, $sizes, $size-multipliers)
$transition-duration
16px
size-map($toggle-indicator-size-base, $sizes, $size-multipliers)
$toggle-indicator-size-base
size-map($toggle-indicator-border-radius-base, $sizes, $size-multipliers)
$color-gray-40
$color-white
$color-primary
$color-white
$color-gray-40
$color-gray-20
mix($toggle-background-active-light, $toggle-background-disabled-light, 25%)
$color-gray-20
$color-dark
$color-white
$color-primary
$color-white
$color-gray-60
$color-gray-20
mix($toggle-background-active-dark, $toggle-background-disabled-dark, 25%)
$color-gray-20
$color-for-light-variant
$color-for-dark-variant
toggle-variant($color-{variant})
(
light: $toggle-variant-light,
dark: $toggle-variant-dark
)
@function toggle-variant($variant) {
$toggle-variant-color: variant-color-by-luminance($variant, $toggle-color-for-light-variant, $toggle-color-for-dark-variant);
$toggle-variant-border-color: variant-color-by-luminance($variant, $border-color-light, $border-color-dark);
$toggle-variant-background: $variant;
$toggle-variant-background-active: $color-primary !default;
$toggle-variant-background-disabled: variant-color-by-luminance($variant, $color-gray-40, $color-gray-60) !default;
$toggle-variant-background-active-disabled: mix($toggle-variant-background-active, $toggle-variant-background-disabled, 25%) !default;
$toggle-variant-indicator-background: $color-white !default;
$toggle-variant-indicator-background-active: $toggle-variant-indicator-background !default;
$toggle-variant-indicator-background-disabled: $color-gray-20 !default;
$toggle-variant-indicator-background-active-disabled: $toggle-variant-indicator-background-disabled !default;
$variant-map: (
color: $toggle-variant-color,
background: $toggle-variant-background,
border-color: $toggle-variant-border-color,
background-active: $toggle-variant-background-active,
background-disabled: $toggle-variant-background-disabled,
background-active-disabled: $toggle-variant-background-active-disabled,
indicator-background: $toggle-variant-indicator-background,
indicator-background-active: $toggle-variant-indicator-background-active,
indicator-background-disabled: $toggle-variant-indicator-background-disabled,
indicator-background-active-disabled: $toggle-variant-indicator-background-active-disabled,
);
@return $variant-map;
}