Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Checkbox as a new web component #27450

Conversation

brianchristopherbrady
Copy link
Contributor

@brianchristopherbrady brianchristopherbrady commented Apr 5, 2023

Checkbox

An implementation of a checkbox as a form-connected web-component.


Design Spec

Link to Checkbox Design Spec in Figma


Engineering Spec

Fluent WC3 Checkbox extends from the FAST Checkbox and is intended to be as close to the Fluent UI React 9 Checkbox implementation as possible. However, due to the nature of web components there will not be 100% parity between the two.


Class: Checkbox


Component Name

<fluent-checkbox>


Component Template

FAST checkboxTemplate


Variables

Name Description Type
checkboxLabelPosition label position types { before: "before", after: "after" }
checkboxShape checkbox shape types { square: "square", circular: "circular" }
checkboxSize checkbox size types { medium: "medium", large: "large" }

Fields

Name Privacy Type Default Description
labelPosition public CheckboxLabelPosition CheckboxLabelPosition.after Indicates postion of label
checked public boolean false Indicates whether input is checked
indeterminate public boolean false Indicates whether input is initially indeterminate
disabled public boolean false Indicates whether input is disabled
required public boolean false Indicates whether input is required
size public CheckboxSize CheckboxSize.medium Indicates the size of the checkbox
shape public CheckboxShape CheckboxShape.square Indicates shape of the checkbox

Methods

Name Privacy Description
keypressHandler public fires on keyboard press
clickHandler public fires on mouse click

Events

Name Type Description Inherited From
change Fires a custom change event FASTCheckbox

Attributes

Name Field
label-position labelPosition
checked checked
disabled disabled
required required
size size
shape shape

IDL Attributes

Name Field Type Description
checked checked boolean The current checked state of the checkbox
indeterminate indeterminate boolean The indeterminate state. Independent of checked

Slots

Name Description
The default slot for text input content
checked-indicator The named slot for the checked indicator
indeterminate-indicator The named slot for the indeterminate indicator



Accessibility

W3C Checkbox Spec


WAI-ARIA Roles, States, and Properties

  • role="checkbox"
  • aria-checked
  • aria-required
  • aria-disabled

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no visible focus indicator on the checkbox:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

align-items: center;
justify-content: center;
color: ${colorNeutralForegroundInverted};
height: 16px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know what the height is good for but is moves the checked indicator 1px down:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

height was no necessary

| --------------- | ------- | ----------------------- | ----------------------------- | -------------------------------------------------- |
| `labelPosition` | public | `CheckboxLabelPosition` | `CheckboxLabelPosition.after` | Indicates postion of label |
| `checked` | public | `boolean` | `false` | Indicates whether input is checked |
| `indeterminate` | public | `boolean` | `false` | Indicates whether input is initially indeterminate |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FUIR9 uses checked: boolean | 'mixed'.
The difference should be covered in Fluent Web Component v3 v.s Fluent React 9 section of the readme


<br />

### **Attributes**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to document Fields and Attributes separately?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been following FASTUI docs on these but this has come up a lot so I have removed the fields table and made sure everything is documented in the attributes table.

| Name | Field |
| ---------------- | ------------- |
| `label-position` | labelPosition |
| `checked` | checked |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing indeterminate


| Name | Description | Type |
| ----------------------- | -------------------- | -------------------------------------------- |
| `checkboxLabelPosition` | label position types | `{ before: "before", after: "after" }` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these variables? I cannot find them anywhere in code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the exported options from checkbox.options.ts

@fabricteam
Copy link
Collaborator

fabricteam commented Jul 17, 2023

🕵 FluentUI-web-components No visual regressions between this PR and main

height: 20px;
}
:host([aria-checked='mixed'][size='large']) .indeterminate-indicator {
width: 10px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The size of the large indeterminate indicator is now 10x8 (for both square and circular), I guess it should be 10x10:
image

@brianchristopherbrady brianchristopherbrady enabled auto-merge (squash) July 18, 2023 16:38
@brianchristopherbrady brianchristopherbrady merged commit 44328d3 into microsoft:web-components-v3 Jul 18, 2023
@fabricteam
Copy link
Collaborator

🕵 fluentui-web-components-v3 No visual regressions between this PR and main

chrisdholt pushed a commit that referenced this pull request Apr 29, 2024
* radio init

* styles radio

* reverts branch

* input spec init

* cleans up spec

* formatting

* updates component name to text input

* updates component name in spec

* checkbox init

* updats checkbox styles

* checkbox: adds attributes to Checkbox

* checkbox: updates checked-indicator svg and storybook templates

* checkbox: updates styles

* checkbox: adds exports

* checkbox: organizes css

* checkbox: updates styles

* checkbox: adds README

* checkbox: formats README

* deletes dead file

* checkbox: cleans up

* checkbox: updates storybook content

* checkbox: removes file

* checkbox: yarn change

* checkbox: updates README

* checkbox: updates styles

* checkbox: fixes styling bug

* checkbox: optimze css

* checkbox: updates storybook

* checkbox: adds required story

* checkbox: updates stories

* Update change/@fluentui-web-components-eba99a5e-947a-4735-815b-86d613000d31.json

Co-authored-by: Miroslav Stastny <[email protected]>

* checkbox: updates README, adds focus styles

* checkbox: api-report

* reverts api report

* checkbox: updates styles

---------

Co-authored-by: Miroslav Stastny <[email protected]>
radium-v pushed a commit to radium-v/fluentui that referenced this pull request Apr 29, 2024
* radio init

* styles radio

* reverts branch

* input spec init

* cleans up spec

* formatting

* updates component name to text input

* updates component name in spec

* checkbox init

* updats checkbox styles

* checkbox: adds attributes to Checkbox

* checkbox: updates checked-indicator svg and storybook templates

* checkbox: updates styles

* checkbox: adds exports

* checkbox: organizes css

* checkbox: updates styles

* checkbox: adds README

* checkbox: formats README

* deletes dead file

* checkbox: cleans up

* checkbox: updates storybook content

* checkbox: removes file

* checkbox: yarn change

* checkbox: updates README

* checkbox: updates styles

* checkbox: fixes styling bug

* checkbox: optimze css

* checkbox: updates storybook

* checkbox: adds required story

* checkbox: updates stories

* Update change/@fluentui-web-components-eba99a5e-947a-4735-815b-86d613000d31.json

Co-authored-by: Miroslav Stastny <[email protected]>

* checkbox: updates README, adds focus styles

* checkbox: api-report

* reverts api report

* checkbox: updates styles

---------

Co-authored-by: Miroslav Stastny <[email protected]>
radium-v pushed a commit to radium-v/fluentui that referenced this pull request Apr 29, 2024
* radio init

* styles radio

* reverts branch

* input spec init

* cleans up spec

* formatting

* updates component name to text input

* updates component name in spec

* checkbox init

* updats checkbox styles

* checkbox: adds attributes to Checkbox

* checkbox: updates checked-indicator svg and storybook templates

* checkbox: updates styles

* checkbox: adds exports

* checkbox: organizes css

* checkbox: updates styles

* checkbox: adds README

* checkbox: formats README

* deletes dead file

* checkbox: cleans up

* checkbox: updates storybook content

* checkbox: removes file

* checkbox: yarn change

* checkbox: updates README

* checkbox: updates styles

* checkbox: fixes styling bug

* checkbox: optimze css

* checkbox: updates storybook

* checkbox: adds required story

* checkbox: updates stories

* Update change/@fluentui-web-components-eba99a5e-947a-4735-815b-86d613000d31.json

Co-authored-by: Miroslav Stastny <[email protected]>

* checkbox: updates README, adds focus styles

* checkbox: api-report

* reverts api report

* checkbox: updates styles

---------

Co-authored-by: Miroslav Stastny <[email protected]>
radium-v pushed a commit to radium-v/fluentui that referenced this pull request Apr 30, 2024
* radio init

* styles radio

* reverts branch

* input spec init

* cleans up spec

* formatting

* updates component name to text input

* updates component name in spec

* checkbox init

* updats checkbox styles

* checkbox: adds attributes to Checkbox

* checkbox: updates checked-indicator svg and storybook templates

* checkbox: updates styles

* checkbox: adds exports

* checkbox: organizes css

* checkbox: updates styles

* checkbox: adds README

* checkbox: formats README

* deletes dead file

* checkbox: cleans up

* checkbox: updates storybook content

* checkbox: removes file

* checkbox: yarn change

* checkbox: updates README

* checkbox: updates styles

* checkbox: fixes styling bug

* checkbox: optimze css

* checkbox: updates storybook

* checkbox: adds required story

* checkbox: updates stories

* Update change/@fluentui-web-components-eba99a5e-947a-4735-815b-86d613000d31.json

Co-authored-by: Miroslav Stastny <[email protected]>

* checkbox: updates README, adds focus styles

* checkbox: api-report

* reverts api report

* checkbox: updates styles

---------

Co-authored-by: Miroslav Stastny <[email protected]>
radium-v pushed a commit that referenced this pull request Apr 30, 2024
* radio init

* styles radio

* reverts branch

* input spec init

* cleans up spec

* formatting

* updates component name to text input

* updates component name in spec

* checkbox init

* updats checkbox styles

* checkbox: adds attributes to Checkbox

* checkbox: updates checked-indicator svg and storybook templates

* checkbox: updates styles

* checkbox: adds exports

* checkbox: organizes css

* checkbox: updates styles

* checkbox: adds README

* checkbox: formats README

* deletes dead file

* checkbox: cleans up

* checkbox: updates storybook content

* checkbox: removes file

* checkbox: yarn change

* checkbox: updates README

* checkbox: updates styles

* checkbox: fixes styling bug

* checkbox: optimze css

* checkbox: updates storybook

* checkbox: adds required story

* checkbox: updates stories

* Update change/@fluentui-web-components-eba99a5e-947a-4735-815b-86d613000d31.json

Co-authored-by: Miroslav Stastny <[email protected]>

* checkbox: updates README, adds focus styles

* checkbox: api-report

* reverts api report

* checkbox: updates styles

---------

Co-authored-by: Miroslav Stastny <[email protected]>
radium-v pushed a commit that referenced this pull request May 2, 2024
* radio init

* styles radio

* reverts branch

* input spec init

* cleans up spec

* formatting

* updates component name to text input

* updates component name in spec

* checkbox init

* updats checkbox styles

* checkbox: adds attributes to Checkbox

* checkbox: updates checked-indicator svg and storybook templates

* checkbox: updates styles

* checkbox: adds exports

* checkbox: organizes css

* checkbox: updates styles

* checkbox: adds README

* checkbox: formats README

* deletes dead file

* checkbox: cleans up

* checkbox: updates storybook content

* checkbox: removes file

* checkbox: yarn change

* checkbox: updates README

* checkbox: updates styles

* checkbox: fixes styling bug

* checkbox: optimze css

* checkbox: updates storybook

* checkbox: adds required story

* checkbox: updates stories

* Update change/@fluentui-web-components-eba99a5e-947a-4735-815b-86d613000d31.json

Co-authored-by: Miroslav Stastny <[email protected]>

* checkbox: updates README, adds focus styles

* checkbox: api-report

* reverts api report

* checkbox: updates styles

---------

Co-authored-by: Miroslav Stastny <[email protected]>
radium-v pushed a commit that referenced this pull request May 2, 2024
* radio init

* styles radio

* reverts branch

* input spec init

* cleans up spec

* formatting

* updates component name to text input

* updates component name in spec

* checkbox init

* updats checkbox styles

* checkbox: adds attributes to Checkbox

* checkbox: updates checked-indicator svg and storybook templates

* checkbox: updates styles

* checkbox: adds exports

* checkbox: organizes css

* checkbox: updates styles

* checkbox: adds README

* checkbox: formats README

* deletes dead file

* checkbox: cleans up

* checkbox: updates storybook content

* checkbox: removes file

* checkbox: yarn change

* checkbox: updates README

* checkbox: updates styles

* checkbox: fixes styling bug

* checkbox: optimze css

* checkbox: updates storybook

* checkbox: adds required story

* checkbox: updates stories

* Update change/@fluentui-web-components-eba99a5e-947a-4735-815b-86d613000d31.json

Co-authored-by: Miroslav Stastny <[email protected]>

* checkbox: updates README, adds focus styles

* checkbox: api-report

* reverts api report

* checkbox: updates styles

---------

Co-authored-by: Miroslav Stastny <[email protected]>
radium-v pushed a commit that referenced this pull request May 2, 2024
* radio init

* styles radio

* reverts branch

* input spec init

* cleans up spec

* formatting

* updates component name to text input

* updates component name in spec

* checkbox init

* updats checkbox styles

* checkbox: adds attributes to Checkbox

* checkbox: updates checked-indicator svg and storybook templates

* checkbox: updates styles

* checkbox: adds exports

* checkbox: organizes css

* checkbox: updates styles

* checkbox: adds README

* checkbox: formats README

* deletes dead file

* checkbox: cleans up

* checkbox: updates storybook content

* checkbox: removes file

* checkbox: yarn change

* checkbox: updates README

* checkbox: updates styles

* checkbox: fixes styling bug

* checkbox: optimze css

* checkbox: updates storybook

* checkbox: adds required story

* checkbox: updates stories

* Update change/@fluentui-web-components-eba99a5e-947a-4735-815b-86d613000d31.json

Co-authored-by: Miroslav Stastny <[email protected]>

* checkbox: updates README, adds focus styles

* checkbox: api-report

* reverts api report

* checkbox: updates styles

---------

Co-authored-by: Miroslav Stastny <[email protected]>
radium-v pushed a commit that referenced this pull request May 3, 2024
* radio init

* styles radio

* reverts branch

* input spec init

* cleans up spec

* formatting

* updates component name to text input

* updates component name in spec

* checkbox init

* updats checkbox styles

* checkbox: adds attributes to Checkbox

* checkbox: updates checked-indicator svg and storybook templates

* checkbox: updates styles

* checkbox: adds exports

* checkbox: organizes css

* checkbox: updates styles

* checkbox: adds README

* checkbox: formats README

* deletes dead file

* checkbox: cleans up

* checkbox: updates storybook content

* checkbox: removes file

* checkbox: yarn change

* checkbox: updates README

* checkbox: updates styles

* checkbox: fixes styling bug

* checkbox: optimze css

* checkbox: updates storybook

* checkbox: adds required story

* checkbox: updates stories

* Update change/@fluentui-web-components-eba99a5e-947a-4735-815b-86d613000d31.json

Co-authored-by: Miroslav Stastny <[email protected]>

* checkbox: updates README, adds focus styles

* checkbox: api-report

* reverts api report

* checkbox: updates styles

---------

Co-authored-by: Miroslav Stastny <[email protected]>
radium-v pushed a commit that referenced this pull request May 6, 2024
* radio init

* styles radio

* reverts branch

* input spec init

* cleans up spec

* formatting

* updates component name to text input

* updates component name in spec

* checkbox init

* updats checkbox styles

* checkbox: adds attributes to Checkbox

* checkbox: updates checked-indicator svg and storybook templates

* checkbox: updates styles

* checkbox: adds exports

* checkbox: organizes css

* checkbox: updates styles

* checkbox: adds README

* checkbox: formats README

* deletes dead file

* checkbox: cleans up

* checkbox: updates storybook content

* checkbox: removes file

* checkbox: yarn change

* checkbox: updates README

* checkbox: updates styles

* checkbox: fixes styling bug

* checkbox: optimze css

* checkbox: updates storybook

* checkbox: adds required story

* checkbox: updates stories

* Update change/@fluentui-web-components-eba99a5e-947a-4735-815b-86d613000d31.json

Co-authored-by: Miroslav Stastny <[email protected]>

* checkbox: updates README, adds focus styles

* checkbox: api-report

* reverts api report

* checkbox: updates styles

---------

Co-authored-by: Miroslav Stastny <[email protected]>
radium-v pushed a commit that referenced this pull request May 6, 2024
* radio init

* styles radio

* reverts branch

* input spec init

* cleans up spec

* formatting

* updates component name to text input

* updates component name in spec

* checkbox init

* updats checkbox styles

* checkbox: adds attributes to Checkbox

* checkbox: updates checked-indicator svg and storybook templates

* checkbox: updates styles

* checkbox: adds exports

* checkbox: organizes css

* checkbox: updates styles

* checkbox: adds README

* checkbox: formats README

* deletes dead file

* checkbox: cleans up

* checkbox: updates storybook content

* checkbox: removes file

* checkbox: yarn change

* checkbox: updates README

* checkbox: updates styles

* checkbox: fixes styling bug

* checkbox: optimze css

* checkbox: updates storybook

* checkbox: adds required story

* checkbox: updates stories

* Update change/@fluentui-web-components-eba99a5e-947a-4735-815b-86d613000d31.json

Co-authored-by: Miroslav Stastny <[email protected]>

* checkbox: updates README, adds focus styles

* checkbox: api-report

* reverts api report

* checkbox: updates styles

---------

Co-authored-by: Miroslav Stastny <[email protected]>
radium-v pushed a commit that referenced this pull request May 8, 2024
* radio init

* styles radio

* reverts branch

* input spec init

* cleans up spec

* formatting

* updates component name to text input

* updates component name in spec

* checkbox init

* updats checkbox styles

* checkbox: adds attributes to Checkbox

* checkbox: updates checked-indicator svg and storybook templates

* checkbox: updates styles

* checkbox: adds exports

* checkbox: organizes css

* checkbox: updates styles

* checkbox: adds README

* checkbox: formats README

* deletes dead file

* checkbox: cleans up

* checkbox: updates storybook content

* checkbox: removes file

* checkbox: yarn change

* checkbox: updates README

* checkbox: updates styles

* checkbox: fixes styling bug

* checkbox: optimze css

* checkbox: updates storybook

* checkbox: adds required story

* checkbox: updates stories

* Update change/@fluentui-web-components-eba99a5e-947a-4735-815b-86d613000d31.json

Co-authored-by: Miroslav Stastny <[email protected]>

* checkbox: updates README, adds focus styles

* checkbox: api-report

* reverts api report

* checkbox: updates styles

---------

Co-authored-by: Miroslav Stastny <[email protected]>
radium-v pushed a commit that referenced this pull request May 10, 2024
* radio init

* styles radio

* reverts branch

* input spec init

* cleans up spec

* formatting

* updates component name to text input

* updates component name in spec

* checkbox init

* updats checkbox styles

* checkbox: adds attributes to Checkbox

* checkbox: updates checked-indicator svg and storybook templates

* checkbox: updates styles

* checkbox: adds exports

* checkbox: organizes css

* checkbox: updates styles

* checkbox: adds README

* checkbox: formats README

* deletes dead file

* checkbox: cleans up

* checkbox: updates storybook content

* checkbox: removes file

* checkbox: yarn change

* checkbox: updates README

* checkbox: updates styles

* checkbox: fixes styling bug

* checkbox: optimze css

* checkbox: updates storybook

* checkbox: adds required story

* checkbox: updates stories

* Update change/@fluentui-web-components-eba99a5e-947a-4735-815b-86d613000d31.json

Co-authored-by: Miroslav Stastny <[email protected]>

* checkbox: updates README, adds focus styles

* checkbox: api-report

* reverts api report

* checkbox: updates styles

---------

Co-authored-by: Miroslav Stastny <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants