Getting started
Add the package
You can use the dotnet add
to add the QuickForm package to your project.
Import the namespace
Import the QuickForm.Components
namespace in your _Imports.razor
or component / page file.
Importing namespaces for customization
If you plan to customize the form, you will also need to import the following namespaces
QuickForm.Attributes
System.ComponentModel
System.ComponentModel.DataAnnotations
@using QuickForm.Components
@using QuickForm.Attributes
@using System.ComponentModel
@using System.ComponentModel.DataAnnotations
Choose your components
QuickForm comes with two default implementations to get you started:
TwQuickForm<TEntity>
- A form component that uses TailwindCSS classes for stylingBsQuickForm<TEntity>
- A form component that uses Bootstrap classes for styling
Customization
if you wish to customize the form to suit your own needs, see Customization
Preview of the components
This is what the components could look like, depending on the one you choose.
The tailwind version has dark mode support and hover effects.
Keep in mind you can always customize and create a custom form, for your specific needs.
Create your model
Decorate your model
Here are some of the most common and basic attributes you can use to customize and flavor the generated form
[Required]
- Marks a property as required[DisplayName]
- Changes the display name of a property - label text[Description]
- Adds a description to the input - text below the input[Placeholder]
- Adds a placeholder to the input - text inside the input[Range]
- Adds a range validation to the input
public class Person
{
[Required]
[Description("We will never disclose your personal details with third parties.")]
public string Name { get; set; }
[Required]
[DisplayName("Your age")]
[Range(18, 100)]
public int Age { get; set; }
}
Attributes
For a list of all available attributes, see Attributes
Create the form
Congratulations!
You now have a fully functional form with validation and submit handling.