-
Notifications
You must be signed in to change notification settings - Fork 161
Checkbox Specification
Team Name: Phoenix
Developer: Zdravko Kolev
Designer: Stefan Ivanov
- Simeon Simeonov | Date:
- Product Owner: Radoslav Mirchev | Date:
- Radoslav Karaivanov | Date:
Version | Users | Date | Notes |
---|---|---|---|
1 | Zdravko Kolev | Date 2 Feb 2017 | Initial spec |
1.1 | Konstantin Dinev | Date 18 Mar 2021 | Adding missing properties |
2 | Stefan Ivanov | Date 21 Jul 2021 | Update spec template |
The <igx-checkbox>
component is used to provide a capability for making a binary choice for a certain condition. It follows the native browser checkbox element and behaves in the same way.
It is providing API for the most common use cases when it comes to making a binary choice for a certain condition.
- The checkbox component should have a toggle visual representation.
- The checkbox component should have a clickable box.
- The checkbox component should be identifiable via a property, like name.
- The checkbox component should represent a unit of information, like value.
- The checkbox component should provide a way to be disabled.
- The checkbox component should provide a way to be a required field.
- The checkbox component should have an indeterminate state.
- The checkbox component should have the ability to add a corresponding label (before or after).
- The checkbox component should be interacted via mouse and/or keyboard.
- The checkbox component should be accessible.
- The checkbox component should emit an event when it gains focus.
- The checkbox component should emit an event when it loses focus.
- The checkbox component should emit an event when its checked status changes.
- The checkbox component should be able to report validation errors in the context of web forms.
Developer stories:
- Story 1: As a developer, I want to be able to provide a way to display a binary choice - true or false.
- Story 2: As a developer, I want to be able to name the checkbox, so that I can easily identify it when used with other selection controls of the same type.
- Story 3: As a developer, I want to be able to set the value of the checkbox, so that I can associate a piece of information with it.
- Story 4: As a developer, I want to be able to specify the default state of the checkbox - checked, unchecked, or indeterminate.
- Story 5: As a developer, I want to be able to disable the checkbox, so that the user cannot change its state.
- Story 6: As a developer, I want to be able to place content between the opening and closing brackets of the checkbox component, so that it can be used as a corresponding label.
- Story 7: As a developer, I want to be able to position the label of the checkbox either before or after the control, so that it better suits the design.
- Story 8: As a developer, I want to be able to programmatically click the checkbox, so that I can interact with it via means other than a computer mouse.
- Story 9: As a developer, I want to be able to programmatically focus the checkbox, so that I can manually trigger the focus event.
- Story 10: As a developer, I want to be able to programmatically blur the checkbox, so that I can manually trigger the blur event.
- Story 11: As a developer, I want to be able to listen to blur, focus, and change events, so that I can better manage the state of the checkbox component.
- Story 12: As a developer, I want to be able to check the validity of the checkbox, so that I can handle form errors and/or warnings.
- Story 13: As a developer, I want to be able to set a custom validation message, so that the users can easily identify and fix form errors and/or warnings.
- Story 14: As a developer, I want to be able to customize the appearance of the checkbox component, so that it better fits the design language of my application.
End-user stories:
- Story 1: As an end-user, I want to be shown a visual representation of certain state changes.
- Story 2: As an end-user, I want to be able to identify if a checkbox is disabled or not.
- Story 3: As an end-user, I want to be able to identify if a checkbox is checked, unchecked, or indeterminate.
- Story 4: As an end-user, I want to be able to identify the option I am selecting via label or some other visual aid.
- Story 5: As an end-user, I want to be able to identify if my selection is valid.
3.1. End-User Experience
The checkbox component represents a small square box that changes its appearance according to the checkbox state. When unchecked, the box has only an outline. Changing the checkbox state to checked or indeterminate, the box became filled and an icon appears inside - a tick mark for checked state and a dash for the indeterminate. The checkbox component comes with an optional corresponding label that can be position either before or after the selection control. The user can click on both the box and the label to change the state of the checkbox.
3.2. Developer Experience
<igx-checkbox [checked]="task.done" (change)="handler($event)">
{{ task.label }}
</igx-checkbox>
3.3. API
You should be able to configure the igx-checkbox
by setting its properties:
Name | Description | Type | Default value | Reflected |
---|---|---|---|---|
name |
Sets the name of the checkbox | string | - | |
value |
Sets the value of the checkbox | string | - | |
checked |
Sets the initial state of the checkbox to checked
|
boolean | false | |
indeterminate |
Sets the initial state of the checkbox to indeterminate
|
boolean | false | |
disabled |
Sets the accessibility state of the checkbox | boolean | false | |
disableRipple |
Enables/Disables the ripple effect | boolean | false | |
disableTransitions |
Sets/gets whether the checkbox should disable all css transitions | boolean | false | |
focused |
Sets/gets whether the checkbox component is on focus | boolean | false | |
readonly |
Sets/gets whether the checkbox is readonly | boolean | false | |
required |
Makes the checkbox a required field | boolean | false | |
label-position |
Sets the label postion of the checkbox | string | after |
The igx-checkbox
should emit the following events:
Name | Description | Type |
---|---|---|
change |
Emitted when the checkbox changes its checked state | - |
The igx-checkbox
exposes the following methods:
Name | Description | Arguments |
---|---|---|
toggle |
If disabled is false, switches the checked state. | - |
Automation
- Scenario 1: Should set the checkbox checked state correctly.
- Scenario 2: Should set the checkbox disabled state correctly.
- Scenario 3: Should set the checkbox required option correctly.
- Scenario 4: Should change the checkbox icon correctly.
- Scenario 5: Should position the checkbox label correctly.
- Scenario 6: Should set the checkbox validity correctly.
- Scenario 7: Should emit event when the checkbox checked state changes.
- Scenario 8: Should emit events when the checkbox gains or loses focus.
-
Roles
: - role="checkbox". https://www.w3.org/TR/wai-aria-1.1/#checkbox
-
Attributes
: - aria-checked="checked". https://www.w3.org/TR/wai-aria-1.1/#aria-checked
- aria-disabled="disabled". https://www.w3.org/TR/wai-aria-1.1/#aria-disabled
- aria-labelledby="labelId". https://www.w3.org/TR/wai-aria-1.1/#aria-labelledby