Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Additional Attributes #1162

Unanswered
curtic00 asked this question in Q&A
Aug 8, 2025 · 4 comments · 1 reply
Discussion options

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

You must be logged in to vote

Replies: 4 comments 1 reply

Comment options

@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" }
 };
}
image
You must be logged in to vote
0 replies
Comment options

Thanks Vikram.Do you have a list of your controls that implements the AdditionalAttributes parameter as I have been unable to find any documentation on it?TIA, regards Charlie Charlie Curtis Worthing, West SussexBN133AB.MCSD, MCSA, MCRDBA, Azure administratorMobile: 0777 254 5516LinkedIn: https://uk.linkedin.com/in/charlieecharlieOn 13 Aug 2025, at 17:20, Vikram Reddy ***@***.***> wrote: @curtic00 Thank you for using BlazorBootstrap. Here is the example: <Button Color="ButtonColor.Primary" ***@***.***"> Primary </Button> @code{ Dictionary<string, object> additionalAttributes = new() { { "data-id", "9HFI94LD580" } }; } image.png (view on web) —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
You must be logged in to vote
1 reply
Comment options

@curtic00 AdditionalAttributes is a default parameter for all components. We will update our documentation.

Comment options

👍👍Charlie Curtis Worthing, West SussexBN133AB.MCSD, MCSA, MCRDBA, Azure administratorMobile: 0777 254 5516LinkedIn: https://uk.linkedin.com/in/charlieecharlieOn 14 Aug 2025, at 13:20, Vikram Reddy ***@***.***> wrote: @curtic00 AdditionalAttributes is a default parameter for all components. We will update our documentation. —Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
You must be logged in to vote
0 replies
Comment options

Hi Vikram I suppose that it would be a lot of work to create a new parameter in your base component and have it bubble up to all of the parent components? Reason that I ask is that I use playwright for all of my integration testing, and the ‘data-testid’ attribute is the Playwright recommended approach for testing. For example, I have nearly 140 instances of data-testid on one page..... Regards Charlie From: Vikram Reddy ***@***.***> Sent: 14 August 2025 13:20 To: vikramlearning/blazorbootstrap ***@***.***> Cc: curtic00 ***@***.***>; Mention ***@***.***> Subject: Re: [vikramlearning/blazorbootstrap] Additional Attributes (Discussion #1162) @curtic00 <https://github.com/curtic00> AdditionalAttributes is a default parameter for all components. We will update our documentation. — Reply to this email directly, view it on GitHub <#1162 (reply in thread)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AUSOJFSPDKB2C3E25GNIEZL3NR5HLAVCNFSM6AAAAACDN7RA76VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTIMJQGMZTGNI> . You are receiving this because you were mentioned.Message ID: ***@***.*** ***@***.***> >
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /