Files
TUIkit/Sources/TUIKit/Views/Box.swift
T
phranck 45e73faafb refactor: Rename package from SwiftTUI to TUIKit
BREAKING CHANGE: Package name changed due to name collision with
existing rensbreur/SwiftTUI package.

Changes:
- Rename package from SwiftTUI to TUIKit in Package.swift
- Rename Sources/SwiftTUI to Sources/TUIKit
- Rename Sources/SwiftTUIExample to Sources/TUIKitExample
- Rename Tests/SwiftTUITests to Tests/TUIKitTests
- Rename SwiftTUI.swift to TUIKit.swift
- Update all imports: import SwiftTUI -> import TUIKit
- Update all code references: SwiftTUI.renderToBuffer -> TUIKit.renderToBuffer
- Update documentation comments
- Rename swiftTUIVersion to tuiKitVersion

All 181 tests passing.
2026-01-28 19:32:09 +01:00

57 lines
1.2 KiB
Swift

//
// Box.swift
// TUIKit
//
// A simple bordered container view.
//
/// A simple bordered container view.
///
/// `Box` wraps content in a border without additional styling.
/// Use `Card` if you need padding and background as well.
///
/// # Example
///
/// ```swift
/// Box {
/// Text("Boxed content")
/// }
///
/// Box(.doubleLine, color: .yellow) {
/// VStack {
/// Text("Line 1")
/// Text("Line 2")
/// }
/// }
/// ```
public struct Box<Content: View>: View {
/// The content of the box.
public let content: Content
/// The border style.
public let borderStyle: BorderStyle
/// The border color.
public let borderColor: Color?
/// Creates a box with the specified border.
///
/// - Parameters:
/// - borderStyle: The border style (default: .line).
/// - color: The border color (default: nil).
/// - content: The content of the box.
public init(
_ borderStyle: BorderStyle = .line,
color: Color? = nil,
@ViewBuilder content: () -> Content
) {
self.content = content()
self.borderStyle = borderStyle
self.borderColor = color
}
public var body: some View {
content.border(borderStyle, color: borderColor)
}
}