feat(react-button,react-divider): headless style hooks for buttons and divider components #35537
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Some of our partners have specific design and technical needs—their designs don't use the Fluent 2 design system, and technically, they prefer to avoid Griffel and fluent tokens.
Solution
TLDR
To address this, we're looking at offering headless or unstyled v9 components. These would provide our components without built-in styles, including only slot classes and state modifier classes (similar to BEM).
Details
The main idea is explained in #35464. We plan to create
.headless.tsstyle hooks that add static classes to component slots based on their state. Consumers would need to adjust their bundler resolution to use theseheadlessfiles when they're available. This method lets us make the change without affecting current functionality. We're already using a similar approach for "raw/unprocessed" styles: https://storybooks.fluentui.dev/react/?path=/docs/concepts-developer-unprocessed-styles--docsHow to use it
.headless.jsfiles when they are availableFluentProvideruseThemelessFluentProviderfrom contrib as we don't want to use Griffel providers.Button/SpinButton/MenuButton/SplitButtonorDivider, as these are the only headless components atmYou can now apply your own styles using custom style hooks supported in headless components, or use any CSS method you prefer to style headless components.
Bundle size comparison
It’s not really a fair comparison since we’re looking at styled vs unstyled components. But like the problem statement says, our partners aren’t interested in using our default styles or Griffel, so they don’t want to deal with the extra bundle or runtime costs for stuff they won’t actually use.
Default
Headless/Unstyled