Description
The MinWidth
property in the BaseStyles
class represents the min-width
CSS property. It is used to set the minimum width of an element, ensuring that the element is not rendered smaller than the specified width. This property is particularly useful for maintaining layout consistency and preventing elements from collapsing to a size smaller than desired.
Usage
To use the MinWidth
property, assign it a value of type Sandbox.UI.Length
. This can be a specific length value such as pixels, percentages, or other CSS length units. The property is nullable, meaning it can be set to null
if no minimum width is desired.
Example
// Example of setting the MinWidth property
var styles = new BaseStyles();
styles.MinWidth = new Length(100, LengthUnit.Pixel); // Sets the minimum width to 100 pixels
// Example of setting MinWidth to a percentage
styles.MinWidth = new Length(50, LengthUnit.Percent); // Sets the minimum width to 50% of the parent element's width
// Example of clearing the MinWidth
styles.MinWidth = null; // Removes the minimum width constraint