API Reference: WidthAttribute Class
The WidthAttribute can be applied to content model properties. The attribute specifies the width of the form field in the user interface of the back office application.
For inline properties, this is the width of the field relative to the other fields in the same row, otherwise, it is the width of the field relative to the form width.
Usage
Decorate the content model property with the WidthAttribute. Pass the width in the attribute constructor as integer pixel width or string CSS width.
When setting a CSS width, the following width options are supported:
- Percentage: a percentage of the containing element's width, f.e. "50%".
- Length units: a specific unit width, f.e. "250px", "10em", "8cm", "400pt".
- "auto": automatically calculates the width based on the content of the field.
- "min-content": the intrinsic minimum width of the content.
- "max-content": the intrinsic maximum width of the content.
- "fit-content": the available width between the min-content and max-content widths.
Example
[Page]
public class ContentPage: IContentType
{
// Set width to min-content so that next inline form field is directly adjacent.
[Width("min-content")]
[Inline("images")]
public Image MainImage { get; set; }
[Inline("images")]
public IReadOnlyList<Image> AdditionalImages { get; set; }
// Set a specific pixel width.
[Width(200)]
[SelectList("Option 1", "Option 2", "Option 3")]
public string Selection { get; set; }
// Set a percentage width.
[Width("80%")]
[Multiline]
public string TextBox { get; set; }
}