All Attributes - Tai-Kimura/SwiftJsonUI GitHub Wiki

All Attributes - SwiftJsonUI Complete Reference

This document provides a comprehensive reference of all attributes available in SwiftJsonUI framework, organized by category and component type.

Table of Contents

Platform Support Legend

  • UIKit: ✅ Supported in UIKit mode
  • SwiftUI: ✅ Supported in SwiftUI (Dynamic) mode
  • Binding: ✅ Supports @{propertyName} data binding

Common Attributes

These attributes are available to most/all components in SwiftJsonUI.

Core Identification & Structure

Attribute Type Description UIKit SwiftUI Binding
id string Unique identifier for the view -
type string View type name (required) -
generatedBy string AI generation command metadata (not rendered) -
include string Include another JSON layout (filename without extension) -
style string Style file name (without extension) -
propertyName string Property name for binding - -
binding_id string Binding ID - -
binding_group string/array Groups related bindings for batch updates -
data array Data model definitions for binding -
child array Child component(s) -
children array Child components (alias for child) -
variables object Variables for include - -
shared_data object Data passed to included components -

Layout & Positioning

Attribute Type Description UIKit SwiftUI Binding
width number/string Width ("matchParent", "wrapContent", or number) - required unless weight specified
height number/string Height ("matchParent", "wrapContent", or number) - required unless weight specified
minWidth number Minimum width
maxWidth number Maximum width
minHeight number Minimum height
maxHeight number Maximum height
widthWeight number Width weight for flexible layouts -
heightWeight number Height weight for flexible layouts -
maxWidthWeight number Maximum width weight -
maxHeightWeight number Maximum height weight -
minWidthWeight number Minimum width weight -
minHeightWeight number Minimum height weight -
aspectWidth number Aspect ratio width -
aspectHeight number Aspect ratio height -
weight number/string Shorthand for widthWeight
rect array Direct frame [x, y, width, height] - -
frame object Frame configuration with width/height -
indexBelow string Place below specified view ID -
indexAbove string Place above specified view ID -

Margins & Padding

Attribute Type Description UIKit SwiftUI Binding
margins number/array Margin as single value or [top, right, bottom, left] -
topMargin number Top margin
bottomMargin number Bottom margin
leftMargin number Left margin
rightMargin number Right margin
startMargin number Start margin (RTL aware)
endMargin number End margin (RTL aware)
minTopMargin number Minimum top margin -
minBottomMargin number Minimum bottom margin -
minLeftMargin number Minimum left margin -
minRightMargin number Minimum right margin -
maxTopMargin number Maximum top margin -
maxBottomMargin number Maximum bottom margin -
maxLeftMargin number Maximum left margin -
maxRightMargin number Maximum right margin -
paddings number/array Padding as single value or [top, right, bottom, left] -
paddingTop number Top padding
paddingBottom number Bottom padding
paddingLeft number Left padding
paddingRight number Right padding
paddingStart number Start padding (RTL aware)
paddingEnd number End padding (RTL aware)
rightPadding number Right padding (alias)
leftPadding number Left padding (alias)
minTopPadding number Minimum top padding - -
minBottomPadding number Minimum bottom padding - -
minLeftPadding number Minimum left padding - -
minRightPadding number Minimum right padding - -
maxTopPadding number Maximum top padding - -
maxBottomPadding number Maximum bottom padding - -
maxLeftPadding number Maximum left padding - -
maxRightPadding number Maximum right padding - -
innerPadding number Inner padding -

Alignment & Centering

Attribute Type Description UIKit SwiftUI Binding
centerInParent boolean Center both horizontally and vertically
centerVertical boolean Center vertically in parent
centerHorizontal boolean Center horizontally in parent
alignTop boolean Align to parent top
alignBottom boolean Align to parent bottom
alignLeft boolean Align to parent left
alignRight boolean Align to parent right
alignTopOfView string Align below specified view ID -
alignBottomOfView string Align above specified view ID -
alignLeftOfView string Align to right of specified view ID -
alignRightOfView string Align to left of specified view ID -
alignTopView string Align top edge with specified view -
alignBottomView string Align bottom edge with specified view -
alignLeftView string Align left edge with specified view -
alignRightView string Align right edge with specified view -
alignCenterVerticalView string Align vertical center with specified view -
alignCenterHorizontalView string Align horizontal center with specified view -
gravity string/array Content gravity: "top", "bottom", "centerVertical", "left", "right", "centerHorizontal", "center" -
toView string Relative layout target view - -

Visual Appearance

Attribute Type Description UIKit SwiftUI Binding
background string Background color - hex (#RRGGBB/#RRGGBBAA) or color name from colors.json
tapBackground string Background color when tapped
highlightBackground string Background color when highlighted
disabledBackground string Background when disabled
defaultBackground string Default background color -
cornerRadius number Corner radius
borderWidth number Border width
borderColor string Border color - hex or color name from colors.json
borderStyle string Border line style: "solid", "dashed", "dotted" -
alpha number Opacity (0-1)
opacity number Opacity (0-1), alias for alpha
shadow string/object Shadow configuration (string 'color|offsetX|offsetY|opacity|radius' or object) -
clipToBounds boolean Clip content to bounds
tintColor string Tint color - hex or color name from colors.json
effectStyle string Visual effect style - -

Interaction & Behavior

Attribute Type Description UIKit SwiftUI Binding
visibility string "visible", "invisible", "gone"
hidden boolean Whether component is hidden
enabled boolean Whether component is enabled
userInteractionEnabled boolean Enable user interaction
canTap boolean Whether component is tappable
onclick string/array Selector-based click handler (calls Objective-C/ViewModel methods) - -
onClick binding Click handler - binding only (@{functionName})
onLongPress binding Long press gesture handler
onPan binding Pan gesture handler
onPinch binding Pinch gesture handler
onAppear string Lifecycle callback when view appears - -
onDisappear string Lifecycle callback when view disappears - -
tag number View tag for identification -
touchDisabledState string Touch disable mode - -
touchEnabledViewIds array IDs of enabled views - -
scripts array Script definitions - -
events object Complex event handlers - -
bindingScript string Custom Swift binding code - -

Layout Priority (UIKit)

Attribute Type Description UIKit SwiftUI Binding
compressHorizontal string Horizontal compression resistance - -
compressVertical string Vertical compression resistance - -
hugHorizontal string Horizontal content hugging - -
hugVertical string Vertical content hugging - -
wrapContent boolean Wrap content - -
keyBottomView string Key bottom view ID - -
keyTopView string Key top view ID - -
keyLeftView string Key left view ID - -
keyRightView string Key right view ID - -

Data Binding

Attribute Type Description UIKit SwiftUI
binding string/object Data binding expression
bind string/object Data binding expression (alias)

Component-Specific Attributes

View / SafeAreaView

Attribute Type Description UIKit SwiftUI Binding
orientation string Stack orientation: "horizontal", "vertical" (default: zstack) -
direction string Layout direction: "topToBottom", "bottomToTop", "leftToRight", "rightToLeft", "none" -
alignment string Alternative child alignment -
distribution string Child distribution: "fill", "fillEqually", "equalSpacing", "equalCentering" - -
spacing number Space between children -
gradient array Gradient colors - -
gradientDirection string Gradient direction - -
locations array Gradient color stop locations - -
highlighted boolean View highlighted state -
safeAreaInsetPositions array Safe area edges: "top", "bottom", "leading", "trailing", "vertical", "all" (SafeAreaView only) -

Label (Text)

Attribute Type Description UIKit SwiftUI Binding
text string Text content (supports interpolation)
font string Font name or 'bold'
fontSize number Font size
fontColor string Font color - hex or color name from colors.json
selected boolean Selected state -
textAlign string Text alignment: "Left", "Center", "Right"
lines number Maximum number of lines (0 for unlimited)
lineBreakMode string Truncation: "Char", "Clip", "Word", "Head", "Middle", "Tail" -
lineHeightMultiple number Line height multiplier
lineSpacing number Line spacing
edgeInset array/string Edge insets -
underline boolean/object/array Underline styling -
strikethrough boolean/object Strikethrough styling -
autoShrink boolean Enable auto-shrink -
minimumScaleFactor number Minimum scale factor for auto-shrink (0-1)
linkable boolean Enable URL/phone detection
textShadow string/object Text shadow configuration -
hint string Placeholder text when empty -
placeholder string Placeholder text (alias for hint) -
hintColor string Hint text color
highlightColor string Font color when selected
highlightAttributes object Highlight styling attributes -
hintAttributes object Hint text styling attributes -
partialAttributes array Partial text styling -

Button

Attribute Type Description UIKit SwiftUI Binding
text string Button text (supports interpolation)
font string Font name or 'bold' -
fontSize number Font size -
fontColor string Font color - hex or color name from colors.json
disabledFontColor string Font color when disabled
highlightColor string Highlight color
hilightColor string Highlight color (typo alias) -
tapBackground string Background when tapped -
highlightBackground string Background when highlighted -
image string Button image -
textAlign string Text alignment: "Left", "Center", "Right" -
config object Button configuration (iOS 15+) - -

Image

Attribute Type Description UIKit SwiftUI Binding
src string Image source name
srcName string Image source name (alias)
highlightSrc string Image when highlighted
highlightSrcName string Highlight image source name -
contentMode string Content mode: "fit", "fill", "center", "top", "bottom", "left", "right", "AspectFill", "AspectFit", etc.
renderingMode string Rendering mode: "original", "template" -

NetworkImage / CircleImage

Attribute Type Description UIKit SwiftUI Binding
src string Image URL
url string Image URL (alias)
hint string Placeholder image name -
placeholder string Placeholder image name (alias) -
defaultImage string Default image name -
errorImage string Error image name -
loadingImage string Loading image name -
contentMode string Content mode
cachePolicy string Cache policy - -
timeout number Download timeout in seconds - -

TextField

Attribute Type Description UIKit SwiftUI Binding
text string Text content (two-way binding)
hint string Placeholder text -
placeholder string Placeholder text (alias) -
hintColor string Placeholder color
hintFont string Placeholder font -
hintFontSize number Placeholder font size -
hintAttributes object Hint text attributes - -
font string Font name or 'bold'
fontSize number Font size
fontColor string Font color
textAlign string Text alignment -
borderStyle string Border style: "none", "line", "bezel", "roundedRect" -
input string Input type: "default", "alphabet", "email", "number", "phone", "url", "password", "decimal" -
returnKeyType string Return key: "Done", "Go", "Next", "Return", "Search", "Send", etc. -
contentType string Content type for autofill
secure boolean Secure text entry for passwords
fieldPadding number Field padding -
textPaddingLeft number Text padding left -
textPaddingRight number Text padding right - -
textVerticalAlign string Text vertical alignment - -
hasContainer boolean Has container view - -
applyLiquidGlass boolean Apply liquid glass effect - -
accessoryCornerRadius number Accessory corner radius - -
glassEffectStyle string Glass effect style - -
accessoryBackground string Input accessory background -
accessoryTextColor string Input accessory text color -
doneText string Done button text -
onTextChange string Text change event handler -
onFocus string Focus event handler -
onBlur string Blur event handler -
onBeginEditing string Begin editing event handler -
onEndEditing string End editing event handler -
leftView object Left view configuration - -
rightView object Right view configuration - -
leftViewMode string Left view display mode - -
rightViewMode string Right view display mode - -

TextView

Attribute Type Description UIKit SwiftUI Binding
text string Text content (two-way binding)
hint string Placeholder text -
placeholder string Placeholder text (alias) -
hintColor string Placeholder color
hintFont string Placeholder font -
hintFontSize number Placeholder font size -
hintLineHeightMultiple number Placeholder line height multiplier -
hintAttributes object Hint styling attributes -
hideOnFocused boolean Hide placeholder when focused (default: true) -
font string Font name or 'bold'
fontSize number Font size
fontColor string Font color
textAlign string Text alignment -
containerInset number/array Container inset -
flexible boolean Enable flexible height -
input string Input type -
returnKeyType string Return key type -
editable boolean Enable/disable editing -
scrollEnabled boolean Enable/disable scrolling -
lineBreakMode string Line break mode -
dataDetectorTypes string Data detector types - -
allowsEditingTextAttributes boolean Allow editing text attributes - -
keyboardType string Keyboard type -
onTextChange string Text change event selector -

Switch (Toggle)

Switch is the primary component name. Toggle is supported as an alias.

Attribute Type Description UIKit SwiftUI Binding
isOn boolean Switch state (two-way binding)
value boolean Switch state alias
checked boolean Switch state alias
bind binding Two-way binding @{variable}
enabled boolean Whether enabled
tint string Tint color
tintColor string Tint color (alias) -
onTintColor string Track color when on -
thumbTintColor string Thumb tint color
offTintColor string Off tint color -
onToggle string Toggle handler function -
onValueChange binding Value change handler
labelAttributes object Label styling for SwiftUI Toggle - -

CheckBox (Check)

CheckBox is the primary component name. Check is supported as an alias.

Attribute Type Description UIKit SwiftUI Binding
label string Checkbox label
text string Checkbox label (alias)
isOn boolean Checked state (two-way binding)
checked boolean Checked state alias
bind binding Two-way binding @{variable}
icon string Icon name for unchecked state -
src string Icon name (alias) -
selectedIcon string Selected icon name -
onSrc string Selected icon name (alias) -
value any Associated value when checked -
enabled boolean Whether enabled
font string Font name
fontSize number Font size
fontColor string Text color
spacing number Space between icon and text
onValueChange binding Value change handler

Radio

Attribute Type Description UIKit SwiftUI Binding
label string Radio label
text string Radio label (alias)
group string Radio group name (required) -
icon string Icon name for normal state -
selectedIcon string Selected icon name -
selected_icon string Selected icon name (underscore alias) -
checked boolean Initial checked state
value any Associated value when selected -
font string Font name
fontSize number Font size
fontColor string Text color
spacing number Space between icon and text

Segment

Attribute Type Description UIKit SwiftUI Binding
items array Segment items (required) -
selectedIndex number Initially selected index (two-way binding)
tintColor string Tint color -
normalColor string Normal state color
selectedColor string Selected state color
valueChange string Value change event -
momentary boolean Momentary selection mode - -
apportionsSegmentWidthsByContent boolean Size segments by content - -

Slider

Attribute Type Description UIKit SwiftUI Binding
value number Current value (two-way binding)
minValue number Minimum value
minimum number Minimum value (alias)
maxValue number Maximum value
maximum number Maximum value (alias)
tintColor string Tint color -
onValueChange binding Value change handler
minimumValueImage string Image at minimum end - -
maximumValueImage string Image at maximum end - -

Progress

Attribute Type Description UIKit SwiftUI Binding
progress number Progress value (0-1)
tintColor string Tint color -
progressTintColor string Progress portion color
trackTintColor string Track portion color
progressViewStyle string Progress view style - -
progressImage string Custom progress image - -
trackImage string Custom track image - -

Indicator

Attribute Type Description UIKit SwiftUI Binding
indicatorStyle string Indicator style: "medium", "large" -
color string Indicator color
hidesWhenStopped boolean Hide when stopped -

SelectBox

Attribute Type Description UIKit SwiftUI Binding
prompt string Prompt text -
hint string Hint text (alias for prompt) -
placeholder string Placeholder text (alias) -
hintColor string Hint text color
items array List of items for normal picker
selectItemType string Select type: "Normal", "Date" -
selectedIndex number Initial selected index (two-way binding)
selectedItem string Selected item value -
selectedDate string Initial selected date (yyyy-MM-dd)
datePickerMode string Date picker mode: "date", "time", "datetime", "dateAndTime", "countDown" -
datePickerStyle string Date picker style: "automatic", "wheel", "wheels", "compact", "graphical", "inline" -
dateStringFormat string Date string format -
minimumDate string Minimum date (yyyy-MM-dd)
maximumDate string Maximum date (yyyy-MM-dd)
minuteInterval number Minute interval: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30 -
font string Font name -
fontSize number Font size -
fontColor string Font color -
labelAttributes object Label styling attributes -
caretAttributes object Caret/arrow styling attributes - -
dividerAttributes object Divider styling attributes - -
canBack boolean Show back button - -
includePromptWhenDataBinding boolean Include prompt in binding - -
inView string Display picker inside view - -
referenceView string Reference view for picker - -
onValueChange binding Value change handler

ScrollView (Scroll)

Attribute Type Description UIKit SwiftUI Binding
child array Child component(s) -
children array Child components -
orientation string Scroll orientation: "horizontal", "vertical" -
showsHorizontalScrollIndicator boolean Show horizontal indicator -
showsVerticalScrollIndicator boolean Show vertical indicator -
paging boolean Enable paging -
bounces boolean Enable bounce effect -
scrollEnabled boolean Enable scrolling
contentInsetAdjustmentBehavior string Content inset adjustment: "never", "always", "automatic", "scrollableAxes" -
maxZoom number Maximum zoom scale
minZoom number Minimum zoom scale
contentSize array Content size [width, height] - -
contentOffset array Initial offset [x, y] - -
decelerationRate string Deceleration rate - -
indicatorStyle string Scroll indicator style - -
keyboardDismissMode string Keyboard dismiss mode -
scrollsToTop boolean Scroll to top on status bar tap - -
keyboardAvoidance boolean Enable keyboard avoidance -

Collection (Table)

Attribute Type Description UIKit SwiftUI Binding
cellClasses array Cell class definitions -
headerClasses array Header class definitions -
footerClasses array Footer class definitions -
columns number Number of columns -
columnSpacing number Spacing between columns -
lineSpacing number Spacing between rows -
horizontalScroll boolean Enable horizontal scroll -
layout string Layout type: "vertical", "horizontal", "Flow" -
orientation string Layout orientation (alias for layout) -
insets array/string Content insets -
insetHorizontal number Horizontal inset -
insetVertical number Vertical inset -
contentInsets array/string Content insets -
contentInsetAdjustmentBehavior string Content inset adjustment -
itemWeight number Item sizing weight -
showsHorizontalScrollIndicator boolean Show horizontal indicator -
showsVerticalScrollIndicator boolean Show vertical indicator -
paging boolean Enable paging -
sections array Section-based configuration (SwiftUI only) - -
items array Data source binding
keyboardAvoidance boolean Enable keyboard avoidance -
setTargetAsDelegate boolean Set target as delegate -
setTargetAsDataSource boolean Set target as data source -

TabView

Attribute Type Description UIKit SwiftUI Binding
selectedIndex number Currently selected tab index (two-way binding)
tabs array Array of tab configurations (required) -
tabs[].title string Tab title text -
tabs[].icon string Tab icon name (SF Symbol for iOS) -
tabs[].selectedIcon string Icon when tab is selected (optional) -
tabs[].iconType string Icon source type: "system", "resource" (default: "system") -
tabs[].badge string/number Badge value
tabs[].view string Layout file name for this tab (without extension) -
tintColor string Selected tab tint color
unselectedColor string Unselected tab color
tabBarBackground string Tab bar background color
showLabels boolean Whether to show tab labels (default: true) -
onTabChange binding Tab change handler

GradientView

Attribute Type Description UIKit SwiftUI
gradient array Gradient colors
gradientDirection string Gradient direction: "Vertical", "Horizontal", "Oblique"
locations array Color stop locations (0.0-1.0)

Blur

Attribute Type Description UIKit SwiftUI
effectStyle string Blur effect style: "Light", "Dark", "ExtraLight"

IconLabel

Attribute Type Description UIKit SwiftUI Binding
text string Label text
selected boolean Selected state -
font string Font name -
fontSize number Font size -
fontColor string Text color -
textShadow string Text shadow -
selectedFontColor string Selected text color -
icon_on string Selected icon -
icon_off string Normal icon -
iconPosition string Icon position: "Left", "Right", "Top", "Bottom" -
iconMargin number Icon-text spacing -

Web

Attribute Type Description UIKit SwiftUI Binding
url string Web page URL
html string HTML content -
allowsBackForwardNavigationGestures boolean Enable swipe navigation -
allowsLinkPreview boolean Enable link preview -

Attribute Types Reference

String Types

  • Color: Hex color (#RRGGBB or #RRGGBBAA), named color from colors.json, or RGB(A) format
  • Font: System font name, custom font, or "bold"
  • ID: View identifier for referencing
  • Path: File path for includes/styles (without extension)
  • URL: Web address for images/pages

Numeric Types

  • Float/Number: Decimal number for sizes, positions
  • Integer: Whole number for counts, indices
  • Array: Multiple values [top, right, bottom, left] or [value1, value2]

Boolean Types

  • Boolean: true/false value
  • String (binding): "@{variableName}" for data binding

Special Types

  • Dictionary/Object: JSON object with nested properties
  • Binding: "@{propertyName}" expression for data binding
  • Any: Any valid JSON value

Data Definition Format

defaultValue Format

The defaultValue in data definitions must be a string containing valid Swift code:

Type Example Description
String "defaultValue": "\"Hello\"" Escaped quotes required
Bool "defaultValue": "false" Boolean as string
Int "defaultValue": "0" Number as string
Dictionary "defaultValue": "[\"key\": \"value\"]" Swift dictionary syntax
Array "defaultValue": "[1, 2, 3]" Swift array syntax
nil "defaultValue": "nil" For optionals

The string content is written directly into generated Swift code.


Best Practices

  1. Required Attributes: Always specify type, width, and height
  2. IDs: Use unique IDs for views that need referencing
  3. Data Binding: Use "@{variableName}" syntax for dynamic values
  4. defaultValue: Must be valid Swift code as a string
  5. Styles: Externalize common attributes to style files
  6. Performance: Use wrapContent judiciously for better performance
  7. Safe Areas: Use SafeAreaView for content that shouldn't be obscured
  8. Events: Prefer single event handlers over complex event dictionaries when possible

See Also

  • Data-Binding - Complete data binding guide with expressions and binding groups
  • Include-System - Component composition and reusability
  • Advanced-Features - Shadow configuration, custom scripts, and advanced techniques
  • Attributes and Attributes-ja - Core attribute reference
  • Individual component documentation for detailed examples