---
title: "init(_:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/horizontalalignment/init(_:)"
---

# init(_:)

Creates a custom horizontal alignment of the specified type.

## Declaration

```swift
init(_ id: any AlignmentID.Type)
```

## Parameters

- `id`: The type of an identifier that uniquely identifies a horizontal alignment.

## Discussion

Discussion Use this initializer to create a custom horizontal alignment. Define an AlignmentID type, and then use that type to create a new static property on HorizontalAlignment: private struct OneQuarterAlignment: AlignmentID {     static func defaultValue(in context: ViewDimensions) -> CGFloat {         context.width / 4     } }

extension HorizontalAlignment {     static let oneQuarter = HorizontalAlignment(OneQuarterAlignment.self) } Every horizontal alignment instance that you create needs a unique identifier. For more information, see AlignmentID.

## See Also

### Creating a custom alignment

- [combineExplicit(_:)](swiftui/horizontalalignment/combineexplicit(_:).md)
