### Scaling Examples Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Examples of setting the scaling. ```swift RadixTheme(scaling: .large) { ... } // Bigger text & spacing ``` ```swift RadixTheme(scaling: .xSmall) { ... } // Compact layout ``` -------------------------------- ### Appearance Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Example of setting the appearance. ```swift RadixTheme(appearance: .dark) { ... } ``` -------------------------------- ### Radius Examples Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Examples of setting the radius. ```swift RadixTheme(radius: .large) { ... } // Rounded appearance ``` ```swift RadixTheme(radius: .full) { ... } // Pill buttons and controls ``` ```swift RadixTheme(radius: .none) { ... } // Sharp corners ``` -------------------------------- ### Quick Start Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/README.md Example of how to wrap your app or feature root in RadixTheme and use RadixSwift components. ```swift import SwiftUI import RadixSwift struct ContentView: View { var body: some View { RadixTheme( appearance: .dark, accentColor: .indigo, grayColor: .auto, radius: .medium, scaling: .normal ) { RadixCard { RadixFlex(direction: .vertical, gap: 3, alignment: .leading) { RadixHeading("Invite members", size: .five) RadixText("Manage team access with native macOS controls.", size: .two) RadixFlex(gap: 2) { RadixButton("Invite") {} RadixButton("Cancel", variant: .soft) {} RadixIconButton(icon: .gear, label: "Settings", variant: .surface) {} } } } .padding(24) } } } ``` -------------------------------- ### Panel Background Examples Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Examples of setting the panel background. ```swift RadixTheme(panelBackground: .solid) { ... } // Opaque dropdowns ``` ```swift RadixTheme(panelBackground: .translucent) { ... } // Glass effect ``` -------------------------------- ### Accent Color Examples Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Examples of setting the accent color. ```swift RadixTheme(accentColor: .ruby) { ... } ``` ```swift RadixTheme(accentColor: .blue) { ... } ``` -------------------------------- ### Gray Color Examples Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Examples of setting the gray color. ```swift RadixTheme(accentColor: .indigo, grayColor: .mauve) { ... } ``` ```swift RadixTheme(accentColor: .amber, grayColor: .sage) { ... } ``` -------------------------------- ### RadixDropdownMenu Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md An example of how to use the RadixDropdownMenu view. ```swift RadixDropdownMenu { RadixButton("Actions", variant: .soft) } content: { RadixMenuItem("Edit") { edit() } RadixMenuItem("Duplicate") { duplicate() } RadixMenuSeparator() RadixMenuItem("Delete", destructive: true) { delete() } } ``` -------------------------------- ### RadixPopover Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md An example of how to use the RadixPopover view. ```swift RadixPopover { RadixButton("Info", variant: .ghost) } content: { RadixFlex(direction: .vertical, gap: 2, alignment: .leading) { RadixText("Helpful information", weight: .bold, size: .one) RadixText("Click the button to open.", size: .one) } .padding(8) } ``` -------------------------------- ### RadixBox Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/layout.md Example of using RadixBox to wrap content. ```swift RadixBox { RadixHeading("Title", size: .six) } ``` -------------------------------- ### RadixHoverCard Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md An example of how to use the RadixHoverCard view. ```swift RadixHoverCard { RadixLink("Learn more", destination: url) } content: { RadixFlex(direction: .vertical, gap: 2, alignment: .leading) { RadixText("Article title", weight: .bold) RadixText("Published 2 days ago", size: .one) } .padding(12) } ``` -------------------------------- ### RadixSwitch Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-form.md Example demonstrating how to use RadixSwitch with different configurations. ```swift @State private var darkMode = true @State private var autoSave = false VStack(alignment: .leading, spacing: 12) { RadixSwitch("Dark mode", isOn: $darkMode) RadixSwitch("Auto-save", isOn: $autoSave, color: .green) RadixSwitch( isOn: $autoSave, size: .three, variant: .soft ) { HStack { RadixIcon(.check, size: 14) Text("Feature enabled") } } } ``` -------------------------------- ### RadixSlider Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-form.md Example demonstrating how to use RadixSlider with different configurations. ```swift @State private var volume = 50.0 @State private var brightness = 75.0 VStack(alignment: .leading, spacing: 12) { VStack(alignment: .leading) { RadixText("Volume: \(Int(volume))", size: .two) RadixSlider(value: $volume, in: 0...100, step: 1) } VStack(alignment: .leading) { RadixText("Brightness", size: .two) RadixSlider(value: $brightness, in: 0...100, step: 5, color: .amber) } } ``` -------------------------------- ### RadixTooltip Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md Examples of how to use the RadixTooltip view with different triggers. ```swift RadixTooltip("Save your work") { RadixIconButton(icon: .save, label: "Save") } RadixTooltip("Delete item") { RadixIcon(.trash, size: 18) } ``` -------------------------------- ### RadixTabNav Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md An example of how to use the RadixTabNav component in Swift. ```swift @State private var page = "home" let pages = [ RadixSelectionOption("home", label: "Home"), RadixSelectionOption("explore", label: "Explore"), RadixSelectionOption("profile", label: "Profile") ] RadixTabNav(selection: $page, tabs: pages) ``` -------------------------------- ### RadixTabs Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md An example of how to use the RadixTabs component in Swift. ```swift @State private var selectedTab = "overview" let tabs = [ RadixSelectionOption("overview", label: "Overview"), RadixSelectionOption("details", label: "Details"), RadixSelectionOption("settings", label: "Settings") ] RadixTabs(selection: $selectedTab, tabs: tabs) { switch selected { case "overview": OverviewView() case "details": DetailsView() case "settings": SettingsView() default: EmptyView() } } ``` -------------------------------- ### RadixInset Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/layout.md Examples demonstrating how to use RadixInset for different padding scenarios. ```swift RadixInset(side: .all, amount: 4) { RadixCard { RadixText("Full padding") } } RadixInset(side: .x, amount: 2) { RadixText("Horizontal padding only") } RadixInset(side: .bottom, amount: 3) { RadixButton("Bottom space only") { } } ``` -------------------------------- ### RadixCard Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md Example of creating a RadixCard with a title, text, and a button. ```swift RadixCard { RadixFlex(direction: .vertical, gap: 2) { RadixHeading("Card Title", size: .four) RadixText("Card content goes here", size: .two) RadixButton("Action") { } } } ``` -------------------------------- ### RadixCheckbox Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-form.md Example demonstrating how to use RadixCheckbox with different configurations. ```swift @State private var termsAccepted = false @State private var notificationsEnabled = false VStack(alignment: .leading, spacing: 8) { RadixCheckbox("Accept terms and conditions", isOn: $termsAccepted) RadixCheckbox("Enable notifications", isOn: $notificationsEnabled, color: .blue) RadixCheckbox( isOn: $notificationsEnabled, size: .three, variant: .soft ) { HStack { RadixIcon(.bell, size: 14) Text("Notifications") } } } ``` -------------------------------- ### Background control examples Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Demonstrates how to control the background fill of the theme. ```swift RadixTheme(hasBackground: true) { ... } // Filled background RadixTheme(hasBackground: false) { ... } // Transparent (layer multiple themes) ``` -------------------------------- ### Theme Nesting Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Demonstrates how to nest themes to apply different configurations to specific parts of the UI. ```swift RadixTheme(appearance: .dark, accentColor: .indigo) { MainContent() // Different theme for modal RadixTheme(appearance: .light, hasBackground: false) { ModalDialog() } } ``` -------------------------------- ### RadixDialog Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md An example of applying the radixDialog ViewModifier in Swift. ```swift @State private var showDialog = false SomeView() .radixDialog(isPresented: $showDialog) { RadixFlex(direction: .vertical, gap: 3, alignment: .leading) { RadixHeading("Confirm Action", size: .five) RadixText("Are you sure?", size: .two) HStack { Spacer() RadixButton("Cancel", variant: .soft) { showDialog = false } RadixButton("Confirm") { showDialog = false performAction() } } } } ``` -------------------------------- ### Configuration Details Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/data-display.md Example of a configuration details card using RadixCard, RadixFlex, RadixHeading, RadixDataList, and RadixButton. ```swift RadixCard { RadixFlex(direction: .vertical, gap: 3, alignment: .leading) { RadixHeading("Settings", size: .five) RadixDataList([ RadixDataListItem(label: "API Key", value: "sk_live_xxxxxxxxxxxx"), RadixDataListItem(label: "Environment", value: "Production"), RadixDataListItem(label: "Webhook URL", value: "https://api.example.com/webhook"), RadixDataListItem(label: "Rate Limit", value: "1000 req/min") ]) RadixButton("Edit Settings") { editSettings() } } } ``` -------------------------------- ### RadixNavigationMenu Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md Example of how to use RadixNavigationMenu to create a navigation interface with NavigationLinks. ```swift RadixNavigationMenu { NavigationLink(destination: HomeView()) { HStack { RadixIcon(.home, size: 18) Text("Home") } } NavigationLink(destination: SettingsView()) { HStack { RadixIcon(.gear, size: 18) Text("Settings") } } } ``` -------------------------------- ### Animation Configuration Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Configure timing and motion for all animated components. ```swift RadixTheme( accentColor: .indigo, animations: RadixAnimationSettings( isEnabled: true, durationScale: 1.0, hover: RadixAnimationSpec(duration: 0.16, curve: .interactiveSpring), press: RadixAnimationSpec(duration: 0.1, curve: .interactiveSpring), toggle: RadixAnimationSpec(duration: 0.22, curve: .spring), popup: RadixAnimationSpec(duration: 0.22, curve: .spring), dialog: RadixAnimationSpec(duration: 0.26, curve: .spring), tooltip: RadixAnimationSpec(duration: 0.16, curve: .interactiveSpring), disclosure: RadixAnimationSpec(duration: 0.22, curve: .spring), presence: RadixAnimationSpec(duration: 0.2, curve: .spring), spinner: RadixAnimationSpec(duration: 0.8, curve: .linear) ) ) { ... } ``` -------------------------------- ### Runtime Theme Switching Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Shows how to dynamically change the theme at runtime using state variables. ```swift @State private var isDarkMode = true var body: some View { RadixTheme(appearance: isDarkMode ? .dark : .light) { AppContent() .toolbar { Button("Toggle Theme") { isDarkMode.toggle() } } } } ``` -------------------------------- ### Fast, snappy animations example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Configures a theme with faster, ease-out animations, specifically for toggles. ```swift RadixTheme( accentColor: .indigo, animations: RadixAnimationSettings( durationScale: 0.7, toggle: RadixAnimationSpec(duration: 0.12, curve: .easeOut) ) ) { ... } ``` -------------------------------- ### RadixCallout Usage Examples Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-buttons.md Examples demonstrating how to use RadixCallout with different configurations for icons, colors, and content. ```swift RadixCallout { RadixText("This feature is in beta and may change.", size: .two) } RadixCallout(icon: .exclamationTriangle, color: .amber) { VStack(alignment: .leading, spacing: 4) { RadixText("Warning", size: .two, weight: .medium) RadixText("Action may have consequences.", size: .two) } } RadixCallout(icon: nil, color: .green) { RadixText("Successfully saved!", size: .two) } ``` -------------------------------- ### RadixIcon Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/icons-colors.md Examples demonstrating how to use RadixIcon in various contexts, including within Flex layouts, buttons, and with custom foreground styles. ```swift RadixFlex(gap: 2) { RadixIcon(.check, size: 18) RadixIcon(.bell, size: 16, accessibilityLabel: "Notifications") RadixIcon(.settings, size: 20) } // In buttons RadixButton(action: { }) { HStack(spacing: 4) { RadixIcon(.save, size: 14) Text("Save") } } // With color RadixIcon(.alertCircle, size: 16) .foregroundStyle(.red) ``` -------------------------------- ### Theme Configuration Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/README.md Demonstrates how to configure the RadixTheme with various appearance, color, and scaling options. ```swift RadixTheme( appearance: .dark, accentColor: .ruby, grayColor: .auto, panelBackground: .translucent, radius: .large, scaling: .normal ) { AppShell() } ``` -------------------------------- ### Primitive Examples Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/README.md Examples of various primitive UI components like Accordion, Tabs, Popover, and Tooltip. ```swift struct PrimitiveExamples: View { @State private var accordionOpen = true @State private var tab = "overview" private let tabs = [ RadixSelectionOption("overview", label: "Overview"), RadixSelectionOption("activity", label: "Activity"), RadixSelectionOption("settings", label: "Settings") ] var body: some View { RadixFlex(direction: .vertical, gap: 3, alignment: .leading) { RadixAccordion(isExpanded: $accordionOpen) { Text("Accordion") } content: { RadixText("Grouped accordion content.", size: .two) } RadixTabs(selection: $tab, tabs: tabs) { RadixText("Selected tab: \(selected)", size: .two) } RadixPopover { RadixButton("Popover", variant: .surface) {} } content: { RadixText("Popover content rendered by SwiftUI.", size: .two) } RadixTooltip("Radix themed tooltip") { RadixBadge("Hover me") } } } } ``` -------------------------------- ### Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/RadixTheme.md An example of how to use RadixTheme to configure the appearance and behavior of child views. ```swift import SwiftUI import RadixSwift struct App: View { var body: some View { RadixTheme( appearance: .dark, accentColor: .indigo, grayColor: .auto, radius: .medium, scaling: .normal, animations: RadixAnimationSettings(durationScale: 1.2) ) { AppContent() } } } struct AppContent: View { @Environment(\.radixTheme) var theme var body: some View { RadixFlex(direction: .vertical, gap: 3) { RadixHeading("Welcome", size: .six) RadixText("Use theme values to access colors and metrics.", size: .two) RadixButton("Action") { print("Theme: \(theme.appearance)") } } .padding(theme.space(4)) } } ``` -------------------------------- ### RadixSpinner Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-buttons.md An example of using RadixSpinner with accompanying text for a loading indicator. ```swift HStack(spacing: 8) { RadixSpinner(size: 14) RadixText("Loading...", size: .two) } ``` -------------------------------- ### RadixProgress Usage Examples Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-buttons.md Examples illustrating RadixProgress with dynamic state updates and fixed values. ```swift @State private var progress = 42.0 VStack(spacing: 8) { RadixProgress(value: progress, total: 100) RadixText("\(Int(progress))%", size: .two) } RadixProgress(value: 2, total: 5, color: .blue) // 40% ``` -------------------------------- ### RadixLink Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/layout.md Example of creating a styled hyperlink using RadixLink. ```swift RadixLink("Visit our website", destination: URL(string: "https://example.com")!) ``` -------------------------------- ### RadixSeparator Usage Examples Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-buttons.md Examples showing RadixSeparator for both horizontal and vertical divisions. ```swift VStack { RadixButton("Option 1") { } RadixSeparator() RadixButton("Option 2") { } } HStack { Text("Left") RadixSeparator(orientation: .vertical) Text("Right") } ``` -------------------------------- ### Light, Playful App Configuration Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Example configuration for a light-themed, playful application. ```swift RadixTheme( appearance: .light, accentColor: .pink, grayColor: .sand, radius: .full, scaling: .large, panelBackground: .solid ) { MyApp() } ``` -------------------------------- ### RadixGrid Usage Examples Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/layout.md Examples showing RadixGrid with a specified column count and a default 2-column responsive grid. ```swift RadixGrid(columns: 3, gap: 2) { ForEach(items, id: \.id) { item in RadixCard { RadixText(item.name, weight: .bold) } } } ``` ```swift // 2-column responsive grid (default) RadixGrid(gap: 3) { RadixCard { content1 } RadixCard { content2 } RadixCard { content3 } RadixCard { content4 } } ``` -------------------------------- ### RadixAlertDialog Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md An example of how to use the RadixAlertDialog modifier in a SwiftUI view. ```swift @State private var showAlert = false SomeView() .radixAlertDialog( isPresented: $showAlert, title: "Delete Account", message: "This action cannot be undone.", confirmTitle: "Delete", destructive: true ) { deleteAccount() } ``` -------------------------------- ### Compact, High-Density UI Configuration Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Example configuration for a compact and high-density user interface. ```swift RadixTheme( accentColor: .gray, grayColor: .slate, radius: .small, scaling: .xSmall, animations: RadixAnimationSettings(durationScale: 0.8) ) { MyApp() } ``` -------------------------------- ### RadixSelect Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-form.md Example of how to implement a RadixSelect dropdown with a title, binding, and options. ```swift @State private var country = "us" let countries = [ RadixSelectionOption("us", label: "United States"), RadixSelectionOption("uk", label: "United Kingdom"), RadixSelectionOption("ca", label: "Canada") ] RadixSelect("Choose country", selection: $country, options: countries) ``` -------------------------------- ### RadixAvatar Usage Examples Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-buttons.md Examples showing RadixAvatar usage with image URLs and fallback text, including a fallback-only scenario. ```swift RadixFlex(gap: 2, alignment: .center) { RadixAvatar( imageURL: URL(string: "https://example.com/avatar.jpg"), fallback: "AB", size: 40 ) RadixText("Alice Bell", size: .two) } // Fallback only (no image) RadixAvatar(fallback: "JS", size: 24) ``` -------------------------------- ### RadixContainer Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/layout.md Example of using RadixContainer to constrain content width. ```swift RadixContainer(size: .three) { RadixFlex(direction: .vertical, gap: 3) { RadixHeading("Max width content") RadixText("This content is centered and width-constrained.") } } ``` -------------------------------- ### RadixAspectRatio Usage Examples Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md Examples demonstrating how to use RadixAspectRatio to create a square or maintain a video's aspect ratio. ```swift RadixAspectRatio(1) { // 1:1 square Image("photo") .resizable() .scaledToFill() } RadixAspectRatio(16 / 9) { // Video VideoPlayer(player: player) } ``` -------------------------------- ### RadixKbd Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/layout.md Example of using RadixKbd to display keyboard key labels. ```swift RadixFlex(gap: 1) { RadixKbd("Cmd") RadixText("+", size: .two) RadixKbd("S") } ``` -------------------------------- ### RadixHeading Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/layout.md Examples of using RadixHeading for different heading levels and styles. ```swift VStack(alignment: .leading, spacing: 4) { RadixHeading("Main Heading", size: .seven) RadixHeading("Subheading", size: .five, weight: .medium) RadixText("Description text", size: .two) } ``` -------------------------------- ### RadixText Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/layout.md Examples of using RadixText with different size, weight, color, and alignment options. ```swift VStack(alignment: .leading, spacing: 8) { RadixText("Regular text", size: .two) RadixText("Bold text", size: .two, weight: .bold) RadixText("Colored", size: .two, color: .blue) RadixText("Right-aligned", size: .three, align: .right) } ``` -------------------------------- ### Slow, bouncy animations example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Configures a theme with slower, spring-based animations, specifically for popups. ```swift RadixTheme( accentColor: .indigo, animations: RadixAnimationSettings( durationScale: 1.5, popup: RadixAnimationSpec(duration: 0.3, curve: .spring) ) ) { ... } ``` -------------------------------- ### RadixSkeleton Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-buttons.md An example demonstrating RadixSkeleton for placeholder content with varying widths and heights. ```swift VStack(alignment: .leading, spacing: 8) { RadixSkeleton(width: 200, height: 24) // Title RadixSkeleton(height: 16) // Text line 1 RadixSkeleton(height: 16) // Text line 2 RadixSkeleton(width: 120, height: 40) // Button } ``` -------------------------------- ### Animation Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/RadixTheme.md Example showing how to customize animation settings like duration scale and specific animation specs for popups and disclosures. ```swift RadixTheme( accentColor: .ruby, animations: RadixAnimationSettings( durationScale: 1.5, popup: RadixAnimationSpec(duration: 0.3, curve: .spring), disclosure: RadixAnimationSpec(duration: 0.25, curve: .easeOut) ) ) { AppContent() } ``` ```swift RadixTheme(animations: .none) { AppContent() } ``` -------------------------------- ### RadixButton Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-buttons.md Examples demonstrating how to use RadixButton with different variants, sizes, and custom labels. ```swift RadixFlex(gap: 2) { RadixButton("Save") { save() } RadixButton("Cancel", variant: .soft) { cancel() } RadixButton("Delete", variant: .solid, size: .three, color: .red) { delete() } // Custom label RadixButton(variant: .outline, action: { next() }) { HStack { Text("Next") RadixIcon(.arrowRight, size: 14) } } } ``` -------------------------------- ### RadixDataList Styled Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/data-display.md Example of styling RadixDataList within a RadixCard. ```swift RadixCard { RadixFlex(direction: .vertical, gap: 3, alignment: .leading) { RadixHeading("User Information", size: .five) RadixDataList([ RadixDataListItem(label: "Username", value: "johndoe"), RadixDataListItem(label: "Email", value: "john@example.com"), RadixDataListItem(label: "Created", value: "Mar 5, 2024"), RadixDataListItem(label: "Last Active", value: "2 hours ago") ]) } } ``` -------------------------------- ### RadixFlex Usage Examples Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/layout.md Examples demonstrating horizontal, vertical, and mixed alignment usage of RadixFlex. ```swift // Horizontal (default) RadixFlex(gap: 2) { RadixButton("Save") { } RadixButton("Cancel", variant: .soft) { } } ``` ```swift // Vertical RadixFlex(direction: .vertical, gap: 3, alignment: .leading) { RadixHeading("Settings", size: .five) RadixText("Configure your preferences", size: .two) RadixCheckbox("Notifications", isOn: $notificationsEnabled) } ``` ```swift // Mixed alignment RadixFlex(gap: 4, alignment: .topLeading) { RadixIcon(.star, size: 20) VStack(alignment: .leading) { RadixText("Feature", weight: .bold) RadixText("Description", size: .two) } } ``` -------------------------------- ### Context Menu Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/README.md Illustrates creating a context menu attached to a RadixCard. ```swift RadixContextMenu { RadixCard { RadixText("Right-click this card for actions.", size: .two) } } menu: { RadixMenuItem("Copy", shortcut: "Cmd C") RadixMenuItem("Paste", shortcut: "Cmd V") RadixMenuSeparator() RadixMenuItem("Delete", destructive: true) } ``` -------------------------------- ### RadixTextField Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-form.md Example of how to use the RadixTextField in a SwiftUI view, demonstrating different configurations. ```swift @State private var email = "" @State private var searchQuery = "" VStack(spacing: 12) { RadixTextField("Email address", text: $email) RadixTextField("Search...", text: $searchQuery, color: .blue) RadixTextField("Large input", text: $email, size: .three, variant: .soft) } ``` -------------------------------- ### RadixDataList Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/data-display.md Example of how to use RadixDataList with an array of items. ```swift let items = [ RadixDataListItem(label: "Name", value: "Alice Johnson"), RadixDataListItem(label: "Email", value: "alice@example.com"), RadixDataListItem(label: "Role", value: "Designer"), RadixDataListItem(label: "Status", value: "Active"), RadixDataListItem(label: "Joined", value: "Jan 15, 2024") ] RadixDataList(items) ``` -------------------------------- ### RadixRadioGroup Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-form.md Example of how to use RadixRadioGroup to create a selection of radio buttons. ```swift @State private var plan = "basic" let plans = [ RadixSelectionOption("basic", label: "Basic - $9/month"), RadixSelectionOption("pro", label: "Pro - $29/month"), RadixSelectionOption("enterprise", label: "Enterprise - Custom") ] RadixRadioGroup(selection: $plan, options: plans) ``` -------------------------------- ### RadixCheckboxCards Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-form.md Example of how to use RadixCheckboxCards for multi-selection of options presented as cards. ```swift @State private var tags: Set = ["swift", "ui"] let options = [ RadixSelectionOption("swift", label: "Swift"), RadixSelectionOption("ui", label: "UI Design"), RadixSelectionOption("mobile", label: "Mobile"), RadixSelectionOption("backend", label: "Backend") ] RadixCheckboxCards(selection: $tags, options: options) ``` -------------------------------- ### RadixContextMenu Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md Demonstrates how to create a context menu with several menu items, including a destructive option. ```swift RadixContextMenu { RadixCard { RadixText("Right-click me") } } menu: { RadixMenuItem("Copy") { copy() } RadixMenuItem("Paste") { paste() } RadixMenuSeparator() RadixMenuItem("Delete", destructive: true) { delete() } } ``` -------------------------------- ### Profile Information Card Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/data-display.md Example of a profile information card using RadixCard, RadixFlex, RadixAvatar, RadixSeparator, and RadixDataList. ```swift RadixCard { RadixFlex(direction: .vertical, gap: 3, alignment: .leading) { HStack { RadixAvatar(fallback: "JD", size: 48) RadixFlex(direction: .vertical, gap: 1, alignment: .leading) { RadixText("Jane Doe", weight: .bold, size: .three) RadixText("Product Manager", size: .one) } } RadixSeparator() RadixDataList([ RadixDataListItem(label: "Email", value: "jane@example.com"), RadixDataListItem(label: "Location", value: "San Francisco, CA"), RadixDataListItem(label: "Member Since", value: "Jan 2023") ]) } } ``` -------------------------------- ### Transaction List Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/data-display.md A SwiftUI code example demonstrating how to create a transaction list using RadixTable, including headers and formatted rows with conditional styling for amounts. ```swift RadixTable { // Header HStack { RadixText("Date", weight: .bold, size: .one) RadixText("Description", weight: .bold, size: .one) RadixText("Amount", weight: .bold, size: .one).frame(alignment: .trailing) } .padding(.bottom, 8) // Rows ForEach(transactions) { tx in HStack { RadixText(tx.dateFormatted, size: .two) RadixText(tx.description, size: .two) RadixText("$\(String(format: \"%.2f\", tx.amount))", size: .two) .foregroundStyle(tx.amount > 0 ? .green : .red) .frame(alignment: .trailing) } .padding(.vertical, 4) } } ``` -------------------------------- ### RadixRadioCards Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-form.md Example of how to use RadixRadioCards for single selection of options presented as cards. ```swift @State private var theme = "light" let themes = [ RadixSelectionOption("light", label: "Light"), RadixSelectionOption("dark", label: "Dark"), RadixSelectionOption("auto", label: "Auto") ] RadixRadioCards(selection: $theme, options: themes) ``` -------------------------------- ### Dropdown Menu Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/README.md Shows how to create a dropdown menu using RadixDropdownMenu with various menu items. ```swift RadixDropdownMenu { RadixButton("Options", variant: .surface) {} } content: { RadixMenuItem("Edit", shortcut: "Cmd E") RadixMenuItem("Duplicate", shortcut: "Cmd D") RadixMenuSeparator() RadixMenuItem("Archive") RadixMenuSubmenu("More") { RadixMenuItem("Move to project...") RadixMenuItem("Move to folder...") RadixMenuSeparator() RadixMenuItem("Advanced options...") } RadixMenuSeparator() RadixMenuItem("Delete", destructive: true) } ``` -------------------------------- ### Summary Statistics Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/data-display.md Example of displaying summary statistics using RadixFlex and RadixDataList. ```swift RadixFlex(direction: .vertical, gap: 2, alignment: .leading) { RadixHeading("Summary", size: .five) RadixDataList([ RadixDataListItem(label: "Total Views", value: "24,582"), RadixDataListItem(label: "Engagement", value: "8.3%"), RadixDataListItem(label: "Conversion Rate", value: "2.1%"), RadixDataListItem(label: "Revenue", value: "$12,345.67") ]) } ``` -------------------------------- ### RadixTextArea Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-form.md Example of how to use the RadixTextArea in a SwiftUI view, showing customization of minHeight and appearance. ```swift @State private var notes = "" @State private var feedback = "" VStack(spacing: 12) { RadixTextArea(text: $notes, minHeight: 120) RadixTextArea(text: $feedback, minHeight: 150, variant: .soft, color: .blue) } ``` -------------------------------- ### RadixBadge Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-buttons.md Examples showing RadixBadge used with text and icons to indicate status or counts. ```swift HStack { RadixHeading("Events", size: .five) RadixBadge("3", color: .amber) } VStack(alignment: .leading, spacing: 8) { HStack { Text("Status") RadixBadge("Live", color: .green) } HStack { Text("Priority") RadixBadge("High", variant: .solid, color: .red) } } ``` -------------------------------- ### RadixScrollArea Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md Example of using RadixScrollArea to create a vertically scrollable list of items. ```swift RadixScrollArea { VStack(spacing: 8) { ForEach(0..<100, id: \.self) { RadixText("Item \(i)", size: .two) } } } ``` -------------------------------- ### RadixCode Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/layout.md Example of using RadixCode for inline monospaced code snippets within text. ```swift RadixText("Use ", size: .two) + RadixCode("RadixTheme", size: .two).view + RadixText(" to configure the theme.", size: .two) ``` -------------------------------- ### RadixIconButton Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/controls-buttons.md Examples of using RadixIconButton with different icons, labels, and styles. ```swift RadixFlex(gap: 2) { RadixIconButton(icon: .gear, label: "Settings", variant: .surface) { openSettings() } RadixIconButton(icon: .plus, label: "Add", color: .green) { addItem() } RadixIconButton(icon: .trash, label: "Delete", variant: .ghost, color: .red) { delete() } } ``` -------------------------------- ### RadixToolbar Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md An example of using RadixToolbar to create a horizontal toolbar with icon buttons and a separator. ```swift RadixToolbar { RadixIconButton(icon: .bold, label: "Bold") { toggle(.bold) } RadixIconButton(icon: .italic, label: "Italic") { toggle(.italic) } RadixSeparator(orientation: .vertical) RadixIconButton(icon: .alignLeft, label: "Align Left") { alignLeft() } } ``` -------------------------------- ### RadixSection Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/layout.md Example demonstrating the use of RadixSection for creating visually distinct content sections with vertical padding. ```swift VStack(spacing: 0) { RadixSection { RadixHeading("First Section") RadixText("Content here") } RadixSeparator() RadixSection { RadixHeading("Second Section") RadixText("More content") } } ``` -------------------------------- ### Theme Hierarchy Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/README.md Illustrates how components inherit theme configuration from a parent RadixTheme. ```swift RadixTheme(accentColor: .indigo) { // All children use .indigo RadixButton("Click me") { } // Uses indigo RadixCheckbox("Accept", isOn: $x) // Uses indigo } ``` -------------------------------- ### Accessible, Slow Motion Configuration Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Example configuration prioritizing accessibility with slower animations. ```swift RadixTheme( accentColor: .indigo, grayColor: .auto, animations: RadixAnimationSettings( durationScale: 2.0, hover: RadixAnimationSpec(duration: 0.32, curve: .easeOut), popup: RadixAnimationSpec(duration: 0.44, curve: .easeOut) ) ) { MyApp() } ``` -------------------------------- ### Table Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/api-overview.md Styled data table wrapper. ```swift RadixTable { TableRow { ... } TableRow { ... } } ``` -------------------------------- ### Dark Professional App Configuration Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Example configuration for a dark-themed professional application. ```swift RadixTheme( appearance: .dark, accentColor: .indigo, grayColor: .slate, radius: .medium, scaling: .normal ) { MyApp() } ``` -------------------------------- ### Glassmorphic Dark Theme Configuration Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Example configuration for a dark theme with a glassmorphic effect. ```swift RadixTheme( appearance: .dark, accentColor: .cyan, panelBackground: .translucent, radius: .large ) { MyApp() } ``` -------------------------------- ### No animations example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/configuration.md Disables all animations within the theme. ```swift RadixTheme(animations: .none) { ... } ``` -------------------------------- ### Buttons, Badges, and Icons Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/README.md Shows various ways to use RadixButton, RadixIconButton, and RadixBadge with different variants, colors, and sizes. ```swift RadixFlex(gap: 2) { RadixButton("Save") { save() } RadixButton("Preview", variant: .surface, color: .blue) { preview() } RadixButton(variant: .solid, size: .three) { goNext() } label: { RadixFlex(gap: 2) { Text("Next") RadixIcon(.arrowRight, size: 14) } } RadixIconButton(icon: .plus, label: "Add item", variant: .soft) { addItem() } RadixBadge("Live", color: .green) RadixBadge("Warning", variant: .surface, color: .amber) } ``` -------------------------------- ### Data List Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/api-overview.md Key-value pair list display. ```swift RadixDataList([ RadixDataListItem(label: "Name", value: "Alice"), RadixDataListItem(label: "Role", value: "Designer") ]) ``` -------------------------------- ### Icons Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/README.md Example of using RadixIcon with different icon names and sizes. ```swift RadixFlex(gap: 2) { RadixIcon(.accessibility, size: 18, accessibilityLabel: "Accessibility") RadixIcon(.checkCircled, size: 18) RadixIcon(.arrowRight, size: 18) } ``` -------------------------------- ### RadixMenubar Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md Demonstrates creating a menu bar with multiple dropdown menus (File, Edit) using RadixMenubar and RadixDropdownMenu. ```swift RadixMenubar { RadixDropdownMenu { Text("File") } content: { RadixMenuItem("New", shortcut: "Cmd N") { newFile() } RadixMenuItem("Open", shortcut: "Cmd O") { open() } } RadixDropdownMenu { Text("Edit") } content: { RadixMenuItem("Undo", shortcut: "Cmd Z") { undo() } RadixMenuItem("Redo", shortcut: "Cmd Shift Z") { redo() } } } ``` -------------------------------- ### Run Demo App Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/README.md Command to run the component catalog demo from SwiftPM. ```bash swift run RadixCatalogDemo ``` -------------------------------- ### Color Access Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/README.md Shows how to retrieve colors from the theme or catalog, considering accent colors and color schemes. ```swift @Environment(\.radixTheme) var theme @Environment(\.colorScheme) var colorScheme Rectangle() .fill(theme.accent(9, colorScheme: colorScheme)) // Accent at step 9 .fill(theme.gray(6, alpha: true, colorScheme: colorScheme)) // Semi-transparent gray ``` -------------------------------- ### Toggle Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/api-overview.md Simple button-style toggle (variant selection). ```swift RadixToggle(isPressed: $isActive) { Text("Active") } ``` -------------------------------- ### RadixMenuSubmenu Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md Illustrates how to create a nested menu structure using RadixMenuSubmenu within a dropdown menu. ```swift RadixDropdownMenu { RadixButton("File", variant: .soft) } content: { RadixMenuItem("New") { } RadixMenuSubmenu("Open Recent") { RadixMenuItem("File 1") { } RadixMenuItem("File 2") { } } RadixMenuSeparator() RadixMenuItem("Exit") { } } ``` -------------------------------- ### Package.swift Installation Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/README.md Shows how to add RadixSwift as a dependency in your Package.swift file. ```swift // Package.swift dependencies: [ .package(url: "https://github.com/adamwawrzynkowski/radixswift", from: "0.1.0") ], targets: [ .target(dependencies: [.product(name: "RadixSwift", package: "radixswift")]) ] ``` -------------------------------- ### RadixAccordion Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/primitives.md An example of how to use the RadixAccordion component in Swift. ```swift @State private var isExpanded = false RadixAccordion(isExpanded: $isExpanded) { Text("Section Title") } content: { RadixText("Expandable content goes here", size: .two) RadixText("Additional content", size: .two) } ``` -------------------------------- ### Dialog and Alert Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/README.md Demonstrates how to present a custom dialog and a standard alert using Radix modifiers. ```swift struct DangerZone: View { @State private var showsDialog = false @State private var showsAlert = false var body: some View { RadixFlex(gap: 2) { RadixButton("Open Dialog", variant: .surface) { showsDialog = true } RadixButton("Revoke", color: .red) { showsAlert = true } } .radixDialog(isPresented: $showsDialog) { RadixFlex(direction: .vertical, gap: 3, alignment: .leading) { RadixHeading("Dialog", size: .five) RadixText("Native overlay styled with the active Radix theme.", size: .two) RadixButton("Close") { showsDialog = false } } } .radixAlertDialog( isPresented: $showsAlert, title: "Revoke access", message: "This application will no longer be accessible.", confirmTitle: "Revoke", destructive: true ) } } ``` -------------------------------- ### Modal Dialog Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/README.md Example of presenting a modal alert dialog. ```swift .radixAlertDialog( isPresented: $showAlert, title: "Delete Item", message: "This action cannot be undone.", confirmTitle: "Delete", destructive: true ) { deleteItem() } ``` -------------------------------- ### Package.swift - Target Dependency Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/README.md Example of how to add the RadixSwift product to your app target in Package.swift. ```swift targets: [ .target( name: "YourApp", dependencies: [ .product(name: "RadixSwift", package: "RadixSwift") ] ) ] ``` -------------------------------- ### Usage Example Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/icons-colors.md Demonstrates how to use RadixColorCatalog to access various color properties like scale steps, alpha variants, theme surfaces, and contrast text. ```swift struct CustomComponent: View { @Environment(\.radixTheme) var theme @Environment(\.colorScheme) var colorScheme var body: some View { let catalog = RadixColorCatalog.shared VStack { // Get step 9 of indigo scale (dark tint) Rectangle() .fill(catalog.color(scale: "indigo", step: 9, appearance: .dark)) // Get alpha variant of gray scale at step 6 Rectangle() .fill(catalog.color(scale: "gray", step: 6, appearance: .light, alpha: true)) // Get theme accent surface Rectangle() .fill(catalog.themeSurface(for: .ruby, appearance: .dark)) // Get contrast text color Text("High contrast text") .foregroundStyle(catalog.themeContrast(for: .indigo)) // Get overlay black Color.clear .overlay(catalog.blackAlpha(8)) // 8% opacity black } } } ``` -------------------------------- ### Toolbar Source: https://github.com/adamwawrzynkowski/radixswift/blob/main/_autodocs/README.md Example of a toolbar with icon buttons, separators, and a dropdown menu. ```swift RadixToolbar { RadixIconButton(icon: .bold, label: "Bold") { } RadixIconButton(icon: .italic, label: "Italic") { } RadixSeparator(orientation: .vertical) RadixDropdownMenu { RadixIconButton(icon: .alignLeft, label: "Align") } content: { RadixMenuItem("Left") { } RadixMenuItem("Center") { } RadixMenuItem("Right") { } } } ```