Declaration
compose().border(
content: SwiftUI.ShapeStyle,
options?: {
width?: number;
}
)nonisolated func border<S>(
_ content: S,
width: CGFloat = 1
) -> some View
where S : ShapeStyleParameters
content*SwiftUI.ShapeStyleA value that conforms to the
ShapeStyleprotocol, like aColororHierarchicalShapeStyle, that SwiftUI uses to fill the border.options.widthnumberThe thickness of the border. The default is 1 pixel.
Return value
A view that adds a border with the specified style and width to this view.
Discussion
Use this modifier to draw a border of a specified width around the view's frame. By default, the border appears inside the bounds of this view. For example, you can add a four-point wide border covers the text:
Text("Purple border inside the view bounds.")
.border(Color.purple, width: 4)To place a border around the outside of this view, apply padding of the same width before adding the border:
Text("Purple border outside the view bounds.")
.padding(4)
.border(Color.purple, width: 4)See also
More in Appearance.
- backgroundSets the view's background to a style.
- badgeGenerates a badge for the view from a localized string resource.
- badgeProminenceSpecifies the prominence of badges created by this view.
- buttonSizingThe preferred sizing behavior of buttons in the view hierarchy.
- containerBackgroundSets the container background of the enclosing container using a view.
- headerProminenceSets the header prominence for this view.
- hiddenHides this view unconditionally.
- imageScaleScales images within the view according to one of the relative sizes available including small, medium, and large images sizes.
- labelIconToTitleSpacingSet the spacing between the icon and title in labels.
- labelReservedIconWidthSet the width reserved for icons in labels.
- labelsHiddenHides the labels of any controls contained within this view.
- labelsVisibilityControls the visibility of labels of any controls contained within this view.