Skip to content

feat(react-card): add useCardBase_unstable hook#35824

Draft
dmytrokirpa wants to merge 4 commits intomasterfrom
feat/react-card-base-hooks
Draft

feat(react-card): add useCardBase_unstable hook#35824
dmytrokirpa wants to merge 4 commits intomasterfrom
feat/react-card-base-hooks

Conversation

@dmytrokirpa
Copy link
Contributor

Summary

This PR adds base state hooks for all Card components as part of the experimental base hooks initiative.

What was implemented

  • useCardBase_unstable — base hook for Card component

    • Props type: CardBaseProps (omits appearance, orientation, size)
    • State type: CardBaseState (omits appearance, orientation, size)
    • Handles: focus mode/interactivity detection (onClick/onMouseDown etc.), selection (controlled/uncontrolled via useCardSelectable), focus management (useFocusWithin, useFocusableGroup), ARIA disabled, slot structure
  • useCardFooterBase_unstable — base hook for CardFooter component

    • Props type: CardFooterBaseProps (same as CardFooterProps — no design props)
    • State type: CardFooterBaseState (same as CardFooterState — no design props)
    • Handles: slot structure (root, action)
  • useCardHeaderBase_unstable — base hook for CardHeader component

    • Props type: CardHeaderBaseProps (same as CardHeaderProps — no design props)
    • State type: CardHeaderBaseState (same as CardHeaderState — no design props)
    • Handles: slot structure, card selectable accessibility (referenceId management for ARIA)
  • useCardPreviewBase_unstable — base hook for CardPreview component

    • Props type: CardPreviewBaseProps (same as CardPreviewProps — no design props)
    • State type: CardPreviewBaseState (same as CardPreviewState — no design props)
    • Handles: slot structure, card selectable label extraction from img elements

Refactoring

  • useCard_unstable now calls useCardBase_unstable and adds appearance, orientation, size
  • useCardFooter_unstable, useCardHeader_unstable, useCardPreview_unstable delegate to their base counterparts

Exports

All new types and hooks are exported from the package index.ts. They are NOT exported from @fluentui/react-components.

Test plan

  • TypeScript compilation passes (npx tsc --noEmit on the package)
  • Existing Card, CardFooter, CardHeader, CardPreview rendering unchanged
  • Card selection and focus behavior works correctly

🤖 Generated with Claude Code

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Pull request demo site: URL

dmytrokirpa and others added 2 commits March 5, 2026 12:08
…er, and CardPreview

Implements base state hooks for all Card components as part of the experimental base hooks initiative.
Each base hook extracts pure component logic while omitting design props.

- CardBaseProps/CardBaseState: omits appearance, orientation, size
  useCardBase_unstable: handles focusMode, interactivity detection, selection (controlled/uncontrolled),
  focus management (useFocusWithin, useFocusableGroup), ARIA disabled, slot structure

- CardFooterBaseProps/CardFooterBaseState: same as CardFooterProps/State (no design props)
  useCardFooterBase_unstable: handles slot structure (root, action)

- CardHeaderBaseProps/CardHeaderBaseState: same as CardHeaderProps/State (no design props)
  useCardHeaderBase_unstable: handles slot structure, card selectable accessibility (referenceId management)

- CardPreviewBaseProps/CardPreviewBaseState: same as CardPreviewProps/State (no design props)
  useCardPreviewBase_unstable: handles slot structure, card selectable label extraction from img elements

All styled hooks now delegate to their base counterparts.
All new types and hooks exported from package index.ts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dmytrokirpa dmytrokirpa changed the base branch from experimental/component-base-hooks to master March 5, 2026 11:09
@dmytrokirpa dmytrokirpa force-pushed the feat/react-card-base-hooks branch from f62e3fa to be7f222 Compare March 5, 2026 11:09
@@ -0,0 +1,7 @@
{
Copy link

@github-actions github-actions bot Mar 5, 2026

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-react-components/CalendarCompat 4 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/CalendarCompat.multiDayView - High Contrast.default.chromium.png 1236 Changed
vr-tests-react-components/CalendarCompat.multiDayView.default.chromium.png 495 Changed
vr-tests-react-components/CalendarCompat.multiDayView.default.chromium_1.png 403 Changed
vr-tests-react-components/CalendarCompat.multiDayView - Dark Mode.default.chromium.png 1107 Changed
vr-tests-react-components/Charts-DonutChart 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Charts-DonutChart.Dynamic - Dark Mode.default.chromium.png 7530 Changed
vr-tests-react-components/Charts-DonutChart.Dynamic - RTL.default.chromium.png 5570 Changed
vr-tests-react-components/Menu Converged - submenuIndicator slotted content 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Menu Converged - submenuIndicator slotted content.default.submenus open.chromium.png 413 Changed
vr-tests-react-components/Menu Converged - submenuIndicator slotted content.default - RTL.submenus open.chromium.png 404 Changed
vr-tests-react-components/Positioning 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Positioning.Positioning end.chromium.png 723 Changed
vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png 505 Changed
vr-tests-react-components/Skeleton converged 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Skeleton converged.Translucent Skeleton with circle - High Contrast.default.chromium.png 1 Changed
vr-tests-react-components/TagPicker 3 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/TagPicker.disabled - Dark Mode.chromium.png 658 Changed
vr-tests-react-components/TagPicker.disabled - High Contrast.disabled input hover.chromium.png 1319 Changed
vr-tests-react-components/TagPicker.disabled - RTL.disabled input hover.chromium.png 635 Changed

There were 4 duplicate changes discarded. Check the build logs for more information.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-card
Card - All
105.131 kB
29.449 kB
105.222 kB
29.475 kB
91 B
26 B
react-card
Card
97.799 kB
27.572 kB
97.84 kB
27.583 kB
41 B
11 B
react-card
CardFooter
12.756 kB
5.109 kB
12.774 kB
5.117 kB
18 B
8 B
react-card
CardHeader
15.289 kB
5.972 kB
15.303 kB
5.976 kB
14 B
4 B
react-card
CardPreview
12.84 kB
5.248 kB
12.854 kB
5.252 kB
14 B
4 B
react-components
react-components: entire library
1.292 MB
323.107 kB
1.292 MB
323.134 kB
99 B
27 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-components
react-components: Button, FluentProvider & webLightTheme
70.397 kB
19.96 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
236.537 kB
68.697 kB
react-components
react-components: FluentProvider & webLightTheme
43.612 kB
14.022 kB
react-portal-compat
PortalCompatProvider
8.386 kB
2.624 kB
react-timepicker-compat
TimePicker
108.174 kB
35.695 kB
🤖 This report was generated against ace36179073ac4600a3635304a0941bd7dcda21d

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant