Checkbox
Checkbox inputs allow the user to select multiple options from a set.
Using the i-checkbox
component together with a i-checkbox-group
allows you to control multiple values using a single binding.
Basic Usage
<i-checkbox v-model="checked">Apple</i-checkbox>
export default {
data () {
return {
checked: true
};
}
}
Checked: true
Checkbox Group
<i-checkbox-group v-model="checked">
<i-checkbox value="Football">Football</i-checkbox>
<i-checkbox value="Volleyball">Volleyball</i-checkbox>
<i-checkbox value="Basketball">Basketball</i-checkbox>
<i-checkbox value="Snowboarding">Snowboarding</i-checkbox>
<i-checkbox value="Tennis" disabled>Tennis</i-checkbox>
</i-checkbox-group>
export default {
data () {
return {
checked: ['Football', 'Basketball', 'Tennis']
};
}
}
[
"Football",
"Basketball",
"Tennis"
]
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-checkbox-group v-model="checked">
<i-checkbox size="sm" value="Football">Football</i-checkbox>
<i-checkbox size="md" value="Volleyball">Tennis</i-checkbox>
<i-checkbox size="lg" value="Basketball">Basketball</i-checkbox>
</i-checkbox-group>
export default {
data () {
return {
checked: ['Basketball']
};
}
}
Applying the size size
property to a i-checkbox-group
will set the chosen size to all of its child inputs.
<i-checkbox-group size="sm" v-model="checked">
<i-checkbox value="Football">Football</i-checkbox>
<i-checkbox value="Volleyball">Volleyball</i-checkbox>
<i-checkbox value="Basketball">Basketball</i-checkbox>
<i-checkbox value="Tennis" disabled>Tennis</i-checkbox>
</i-checkbox-group>
<i-checkbox-group size="md" v-model="checked">
<i-checkbox value="Football">Football</i-checkbox>
<i-checkbox value="Volleyball">Volleyball</i-checkbox>
<i-checkbox value="Basketball">Basketball</i-checkbox>
<i-checkbox value="Tennis" disabled>Tennis</i-checkbox>
</i-checkbox-group>
<i-checkbox-group size="lg" v-model="checked">
<i-checkbox value="Football">Football</i-checkbox>
<i-checkbox value="Volleyball">Volleyball</i-checkbox>
<i-checkbox value="Basketball">Basketball</i-checkbox>
<i-checkbox value="Tennis" disabled>Tennis</i-checkbox>
</i-checkbox-group>
export default {
data () {
return {
checked: ['Basketball', 'Tennis']
};
}
}
Custom vs. Native
Inkline uses custom checkbox designs by setting the custom
property to true
by default.
<i-checkbox-group v-model="checkedCustomTrue">
<i-checkbox :custom="true" value="Football">Football</i-checkbox>
<i-checkbox :custom="true" value="Volleyball">Tennis</i-checkbox>
<i-checkbox :custom="true" value="Basketball">Basketball</i-checkbox>
</i-checkbox-group>
export default {
data () {
return {
checked: ['Basketball']
};
}
}
Indeterminate
You can set the state of a <i-checkbox>
to be indeterminate by setting the indeterminate
property to true
.
<i-checkbox :indeterminate="true">Football</i-checkbox>
export default {
data () {
return {
checked: ['Basketball']
};
}
}
Checkbox Buttons
You can display your checkbox inputs as toggleable buttons using the provided <i-checkbox-button>
and <i-checkbox-button-group>
components.
<i-checkbox-button-group v-model="checked">
<i-checkbox-button value="Earth">Earth</i-checkbox-button>
<i-checkbox-button value="Mars">Mars</i-checkbox-button>
<i-checkbox-button value="Jupiter">Jupiter</i-checkbox-button>
<i-checkbox-button value="Venus" disabled>Venus</i-checkbox-button>
</i-checkbox-button-group>
export default {
data () {
return {
checked: ['Earth']
};
}
}
Component API
Here you can find a list of the various customization options you can use for the checkbox components as props, as well as available slots and events.
Boolean
true
, false
true
Boolean
true
, false
false
Boolean
true
, false
false
Boolean
true
, false
false
Object
String
sm
, md
, lg
md
Boolean
, String
v-model
directive when the checkbox isn't grouped.(event: Event) => {}
(event: Event) => {}
(event: Event) => {}
(value: Boolean | String) => {}
Boolean
true
, false
false
Boolean
true
, false
false
String
sm
, md
, lg
md
Array<String>
[]
v-model
directive.(event: Event) => {}
(event: Event) => {}
(value: Boolean | String) => {}
Sass Variables
Here you can find a list of the Sass variables you can use for the checkbox and radio components. If you're looking to find common variables that these rely on, you should take a look at the Sass Variables page.
$border-radius
8px
size-map($form-check-checkbox-icon-size-base, $sizes, $size-multipliers)
$text-muted
$spacer
$color-black
$color-white
$color-white
$color-gray-30
$color-primary
$color-primary
$color-gray-40
$color-gray-40
$color-gray-60
1rem
spacers('1/2')
$form-check-indicator-size / 4
0 0 0 1px rgba($color-black, 0.2), inset 0 0.25rem 0.25rem rgba($color-black, 0.1)
0 0 0 1px $body-background, 0 0 0.2rem 0.2rem rgba($color-primary, 0.33)
none
none
0.5rem
$color-for-light-variant
$color-for-dark-variant
checkable-variant($color-{variant})
(
light: $checkable-variant-light,
dark: $checkable-variant-dark
)
@function checkable-variant($variant) {
$checkable-variant-indicator-background: $variant;
$checkable-variant-indicator-color: $color-black;
$checkable-variant-indicator-checked-color: $color-white;
$checkable-variant-indicator-active-color: $color-white;
$checkable-variant-indicator-disabled-color: $color-gray-30;
$checkable-variant-indicator-checked-background-color: $color-primary;
$checkable-variant-indicator-active-background-color: $color-primary;
$checkable-variant-indicator-disabled-background-color: $color-gray-40;
$checkable-variant-indicator-disabled-checked-background-color: variant-color-by-luminance($variant, $color-gray-40, $color-gray-60);
$checkable-variant-indicator-box-shadow: 0 0 0 1px rgba($color-black, 0.2), inset 0 0.25rem 0.25rem rgba($color-black, 0.1) !default;
$checkable-variant-indicator-focused-box-shadow: 0 0 0 1px $body-background, 0 0 0.2rem 0.2rem rgba($color-primary, 0.33) !default;
$checkable-variant-indicator-checked-box-shadow: none !default;
$checkable-variant-indicator-active-box-shadow: none !default;
$checkable-variant-indicator-background-size: 0.5rem !default;
$variant-map: (
indicator-background: $checkable-variant-indicator-background,
indicator-color: $checkable-variant-indicator-color,
indicator-checked-color: $checkable-variant-indicator-checked-color,
indicator-active-color: $checkable-variant-indicator-active-color,
indicator-disabled-color: $checkable-variant-indicator-disabled-color,
indicator-checked-background-color: $checkable-variant-indicator-checked-background-color,
indicator-active-background-color: $checkable-variant-indicator-active-background-color,
indicator-disabled-background-color: $checkable-variant-indicator-disabled-background-color,
indicator-disabled-checked-background-color: $checkable-variant-indicator-disabled-checked-background-color,
indicator-box-shadow: $checkable-variant-indicator-box-shadow,
indicator-focused-box-shadow: $checkable-variant-indicator-focused-box-shadow,
indicator-checked-box-shadow: $checkable-variant-indicator-checked-box-shadow,
indicator-active-box-shadow: $checkable-variant-indicator-active-box-shadow,
indicator-background-size: $checkable-variant-indicator-background-size
);
@return $variant-map;
}