Skip to content

feat: add defaultindeterminate attribute to checkbox for setting indeterminate declaratively - #36514

Open
Chris Holt (chrisdholt) wants to merge 2 commits into
microsoft:masterfrom
chrisdholt:users/chhol/add-defaultindeterminate-attribute
Open

feat: add defaultindeterminate attribute to checkbox for setting indeterminate declaratively#36514
Chris Holt (chrisdholt) wants to merge 2 commits into
microsoft:masterfrom
chrisdholt:users/chhol/add-defaultindeterminate-attribute

Conversation

@chrisdholt

Copy link
Copy Markdown
Member

Previous Behavior

On the HTML Platform there is currently no way to have indeterminate exist at runtime without hydration, this issue also exists with the current Fluent checkbox.

New Behavior

This PR proposes a new defaultindeterminate attribute to support setting indeterminate declaratively. The proposed approach follows the discussion and direction provided in whatwg.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

📊 Bundle size report

✅ No changes found

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Pull request demo site: URL

@@ -0,0 +1,7 @@
{

@github-actions github-actions Bot Aug 5, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-web-components/Badge 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/Badge. - Dark Mode.normal.chromium.png 443 Changed

Comment thread packages/web-components/src/checkbox/checkbox.ts Outdated
}

this.dirtyIndeterminate = true;
toggleState(this.elementInternals, 'dirty-indeterminate', true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a true need for a dirty-indeterminate state? We don't have a separate state for dirty-checked.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There is a reason for this, and I think it's one-of-a-kind situation (maybe I missed something simpler). Consider the lifecycle of defaultindeterminate.

  1. A server-rendered indeterminate means we hook off the attribute for initial visual styling (avoid using states which should be client-side only). The checkbox appears as indeterminate.
  2. Click the checkbox => checkbox shows checked and no longer indeterminate, attribute styling is preserved for defaultindeterminate
  3. Click the checkbox again => checkbox is unchecked, attribute styling is preserved for defaultindeterminate

We need to preserve the attribute that's passed from the client (we should not remove this or toggle upon user interaction). We need a way to essentially say, "This is no longer indeterminate" while preserving the attribute from user-land. I chose a state here because it explicitly applies client-side.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm open to naming on the state, but absent another solution it seems the most elegant to address what is purely a styling problem post-user-interaction.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think this still needs to exist...or I'm being dense.

:host([defaultindeterminate]):not(:state(${indeterminateState})) {}

In a scenario where we render DSD, defaultchecked manages the initial visual presentation. On user interaction, CSS state would no longer be indeterminate (as above)...but the host styling would still apply, because the attribute still exists.

Comment thread packages/web-components/src/checkbox/checkbox.ts
@chrisdholt
Chris Holt (chrisdholt) force-pushed the users/chhol/add-defaultindeterminate-attribute branch from 16f65cf to c70c889 Compare August 14, 2026 17:59
@chrisdholt
Chris Holt (chrisdholt) force-pushed the users/chhol/add-defaultindeterminate-attribute branch from c70c889 to 998e7ff Compare August 14, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants