Fluentui: ITextFieldStyle: Style props should be optional

Created on 16 Nov 2018  路  4Comments  路  Source: microsoft/fluentui

Please provide a reproduction of the bug in a codepen:

Currently ITextFieldStyles requires all the styles to be required which can lead to a lot of empty styles if the user only wants to add one change.

I see examples of both being used. IButtonStyles allow everything to be optional. ISpinButtonStyles requires everything.

What are thoughts on making these optional?

Priorities and help requested:

Are you willing to submit a PR to fix? Yes

Requested priority: Low

Products/sites affected: (if applicable)

TextField Cleanup

Most helpful comment

@chang47 I remember having the same question once. The answer I got was that the intent is to have them all required but somehow was not enforced when PRs introduced them as optional for a number of components.

A solution from the same discussion came in the form of using a Partial which BTW is in the wiki here. So in order for you not to be forced to add a lot of empty styles you would do something like this:

const textFieldStyles: Partial<ITextFieldStyles> = {
    root: {
        // your styles
    }
}

Hope this answers your question. Changing them all to required would need to be discussed in more depth with the team. @dzearing FIY

All 4 comments

@chang47 I remember having the same question once. The answer I got was that the intent is to have them all required but somehow was not enforced when PRs introduced them as optional for a number of components.

A solution from the same discussion came in the form of using a Partial which BTW is in the wiki here. So in order for you not to be forced to add a lot of empty styles you would do something like this:

const textFieldStyles: Partial<ITextFieldStyles> = {
    root: {
        // your styles
    }
}

Hope this answers your question. Changing them all to required would need to be discussed in more depth with the team. @dzearing FIY

Got it, thank you for explaining this to me!

@chang47 if the solution I provided solves your issue feel free to close the issue or let us know if you have any suggestions or feedback. Thanks for getting this to our attention 馃憤

Will do, I'll close it now.

Was this page helpful?
0 / 5 - 0 ratings