Adding a Parameter to a Component

Learn how to add parameters to components for customized functionality.

Most components require parameters. To add a parameter to a component, use the Parameter attribute. We will add a parameter to specify the increment used by the IncrementCount method. We do this as follows:

  1. Return to Visual Studio.
  2. Open the Pages\Counter.razor file.
  3. Add the following code to the top of the code block to define the new parameter:

Get hands-on with 1400+ tech skills courses.