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

Ability to override/merge custom interface with Theme declaration #20513

Closed
jtbandes opened this issue Nov 4, 2021 · 3 comments
Closed

Ability to override/merge custom interface with Theme declaration #20513

jtbandes opened this issue Nov 4, 2021 · 3 comments
Assignees
Labels

Comments

@jtbandes
Copy link

jtbandes commented Nov 4, 2021

The styled-components library has a nice feature for TypeScript users: declaration merging can be used to change the DefaultTheme type as described here: https://styled-components.com/docs/api#create-a-declarations-file

It would be nice if Fluent also had this feature, so any calls to useTheme() or calls to makeStyles((theme) => ...) would reference the custom Theme type.

This would allow the user to do something like:

declare module "@fluentui/react-theme" {
  export interface Theme {
    fluxCapacitorColor: string; // define a custom slot that will be available across the codebase
  }
}

<ThemeProvider theme={{fluxCapacitorColor: "#abcdef"}} />

<div style={{backgroundColor: useTheme().fluxCapacitorColor}} />
@khmakoto
Copy link
Member

Hi @jtbandes, I don't know if we would ever allow declaration merging because that can open a can of wormholes, but I do think that adding extensibility into our Theme would be a good thing to do going forward. We'll keep this in our conversations for the future.

@jtbandes
Copy link
Author

Declaration merging is a common approach also used by Emotion and MUI:

emotion-js/emotion#1609

https://mui.com/customization/theming/#custom-variables

@gouttierre gouttierre moved this from TBD to Backlog in Fluent UI - Shield Priors Feb 3, 2022
@msft-fluent-ui-bot msft-fluent-ui-bot added the Resolution: Soft Close Soft closing inactive issues over a certain period label Aug 2, 2022
@msft-fluent-ui-bot
Copy link
Collaborator

Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes.

Still require assistance? Please, create a new issue with up-to date details.

Repository owner moved this from Backlog to Done in Fluent UI - Shield Priors Aug 2, 2022
@microsoft microsoft locked as resolved and limited conversation to collaborators Sep 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Development

No branches or pull requests

4 participants