Skip to content

Instantly share code, notes, and snippets.

@kasima
Last active May 28, 2023 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasima/51907512d7e18cb121e5dbb064a074ac to your computer and use it in GitHub Desktop.
Save kasima/51907512d7e18cb121e5dbb064a074ac to your computer and use it in GitHub Desktop.
SwiftUI Styling Cheat Sheet

Styling Text

Text(talkModel.promptText)
    .font(.title)
    .padding()
    .frame(maxWidth: .infinity)
    .background(.ultraThinMaterial)
    .foregroundColor(Color(UIColor.label))

.font

font(.body)

  • .body
  • .callout
  • .caption
  • .caption2
  • .footnote
  • .headline
  • .largeTitle
  • .subheadline
  • .title
  • .title2
  • .title3

Color(UIColor.systemGray)

Adaptable colors

  • .systemBlue
  • .systemBrown
  • .systemCyan
  • .systemGreen
  • .systemIndigo
  • .systemMint
  • .systemOrange
  • .systemPink
  • .systemPurple
  • .systemRed
  • .systemTeal
  • .systemYellow

Adaptable gray colors

  • .systemGray
  • .systemGray2
  • .systemGray3
  • .systemGray4
  • .systemGray5
  • .systemGray6

Transparent color

  • .clear

Fixed colors

  • .black
  • .blue
  • .brown
  • .cyan
  • .darkGray
  • .gray
  • .green
  • .lightGray
  • .magenta
  • .orange
  • .purple
  • .red
  • .white
  • .yellow

TextField

Textfield("Name", text: $text)
  .onSubmit {
     action()
   }
   .submitLabel(.send)
   .textSelection(.enabled)
   .textFieldStyle(.roundedBoder)
   .disableAutocorrection(false)
   .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment