Parameters
An array of presentation detents that define the available sheet sizes. Use Detent.medium, Detent.large, Detent.height(number), or Detent.fraction(number).
Configures the available sizes for sheet presentation.
.presentationDetents(detents: PresentationDetents): Component;
VStack([
Button("Show Sheet", () => {
showingSheet = true;
})
]).sheet(isPresented: $showingSheet, content: () =>
VStack([
Text("Sheet Content"),
Button("Dismiss", () => {
showingSheet = false;
})
]).presentationDetents([Detent.medium, Detent.large])
)
VStack([
Text("Sheet with custom size")
]).presentationDetents([Detent.height(300), Detent.large])
VStack([
Text("This sheet only shows at medium height")
]).presentationDetents([Detent.medium])
VStack([
Text("Full screen content")
]).presentationDetents([Detent.large])
VStack([
Text("Multiple size options")
]).presentationDetents([
Detent.height(200),
Detent.height(400),
Detent.large
])
List([
NavigationLink("Account", destination: AccountView()),
NavigationLink("Privacy", destination: PrivacyView()),
NavigationLink("Notifications", destination: NotificationsView())
]).presentationDetents([Detent.medium, Detent.large])
LazyVGrid(columns: gridColumns, content: () => [
ForEach(photos, (photo) =>
Image(photo.thumbnail)
)
]).presentationDetents([
Detent.height(300),
Detent.height(500),
Detent.large
])
const [minPrice, setMinPrice] = useState("")
const [maxPrice, setMaxPrice] = useState("")
Form([
Section("Price Range", content: () => [
TextField({ placeholder: "Min", text: minPrice, setText: setMinPrice }),
TextField({ placeholder: "Max", text: maxPrice, setText: setMaxPrice })
]),
Section("Category", content: () => [
Picker("Category", selection: $selectedCategory, content: () =>
ForEach(categories, (category) =>
Text(category.name).tag(category.id)
)
)
])
]).presentationDetents([Detent.height(350)])