Class ComponentPreview<T>
Base class for defining component previews. Inherit from this class and use AddPreview() to define preview scenarios.
Implements
Inherited Members
Namespace: BlazorToolkit.Previews
Assembly: BlazorToolkit.Previews.dll
Syntax
public abstract class ComponentPreview<T> : IComponentPreview<T>
Type Parameters
| Name | Description |
|---|---|
| T | The component type to preview. |
Examples
public class ButtonPreviews : ComponentPreview<Button>
{
public ButtonPreviews()
{
AddPreview("Primary")
.WithParameter(b => b.Variant, "primary")
.WithParameter(b => b.Text, "Click me");
AddPreview("Disabled")
.WithParameter(b => b.Disabled, true);
}
}
Constructors
ComponentPreview()
Declaration
protected ComponentPreview()
Methods
AddPreview(string)
Adds a new preview configuration for the component.
Declaration
protected ComponentPreview<T>.PreviewBuilder AddPreview(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Display name for the preview. |
Returns
| Type | Description |
|---|---|
| ComponentPreview<T>.PreviewBuilder | A builder to configure the preview parameters and services. |
GetPreviews()
Gets all preview definitions for the component.
Declaration
public IEnumerable<Preview> GetPreviews()
Returns
| Type | Description |
|---|---|
| IEnumerable<Preview> |