-
-
Notifications
You must be signed in to change notification settings - Fork 93
-
Hi.
Does anyone have any good examples of using Additional Attributes parameter in components?
reason that I am asking is that I use Playwright extensively for testing, and the stated best practice is to give each component an attribute 'data-testid' , eg. data-testid="MenuButtonWelcome".
Is it acceptable to just add such a tag into a component , eg: <Button data-testid="MenuButtonWelcome" Color="ButtonColor.Secondary" .....
Or must one use the AdditionalAttributes parameter?
If so, must one declare a Dictionary variable in the code section, or can one just create the Dictionary ' in place' ?
i.e. AdditionalAttributes="@(new Dictionary<string,object>(){{"data-testid", "MenuButtonWelcome"}} )"
Any help or guidance appreciated .
TIA
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 4 comments 1 reply
-
@curtic00 Thank you for using BlazorBootstrap.
Here is the example:
<Button Color="ButtonColor.Primary" AdditionalAttributes="@additionalAttributes"> Primary </Button> @code{ Dictionary<string, object> additionalAttributes = new() { { "data-id", "9HFI94LD580" } }; }
Beta Was this translation helpful? Give feedback.
All reactions
-
Beta Was this translation helpful? Give feedback.
All reactions
-
@curtic00 AdditionalAttributes is a default parameter for all components. We will update our documentation.
Beta Was this translation helpful? Give feedback.
All reactions
-
Beta Was this translation helpful? Give feedback.
All reactions
-
Beta Was this translation helpful? Give feedback.