> For the complete documentation index, see [llms.txt](https://eneskaraosman53.gitbook.io/swiftui/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eneskaraosman53.gitbook.io/swiftui/ui-components/button.md).

# Button

Tetiklendiği zaman aksiyon almamızı sağlayan bir kontrol bileşeni.

**Kullanım**

```swift
// 1) En temel kullanım
// Bu kullanımda text'e müdahil olmaktan feragat etmiş oluyoruz.
Button("Button Title") {
    // Aksiyon
}
.padding()
.background(Color.green)

// 2) Burada ise Text'i istediğimiz gibi düzenleyebiliriz.
Button(action: {
    // Aksiyon
}) {
    Text("Button Title")
        .fontWeight(.bold)
        ...
        ...
}
```

**Custom Style**

```swift
struct MyButtonStyle: ButtonStyle {
    func makeBody(configuration: Configuration) -> some View {
        LinearGradient(
            gradient: .init(colors: [.red, .orange]),
            startPoint: .leading,
            endPoint: .trailing
        )
        .clipShape(Capsule())
        .overlay(
            // ** Burada asıl Text'i yerleştiriyoruz.
            configuration.label
                .foregroundColor(.white)
        )
        .frame(height: 50) // Default height
        .padding() // Default padding
    }
}

// Custom Style kullanımı
Button("Tap Me !!") {
    // Aksiyon
}
.buttonStyle(MyButtonStyle())
.font(.system(size: 20, weight: .bold, design: .monospaced))
```

Custom style neticemiz aşağıdaki gibi gözlemlenebilir.

![custom styled button](https://1761232408-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M5Upqg27mOVmaED1CFL%2F-M5fwjMcQ_NWp9om7NsV%2F-M5g-DOrSDoT_xnUyeoG%2FScreen%20Shot%202020-04-24%20at%2014.44.25.png?alt=media\&token=bb022d40-cf3e-4f72-98c8-7fb396b28e79)

Mesela uygulama içinde sık kullanılan tasarımlar var ise, bu tarz Custom Style oluşturarak kod tekrarından kurtulabiliriz.
