iOS 16.4+ iPadOS 16.4+
Triggers an action or event, such as submitting a form.
import SwiftUI struct ButtonUsageExample : View { var body: some View { VStack ( spacing : FLXSpacing.md ) { FLXButton ( "Primary" , variant : .primary ) {} FLXButton ( "Destructive" , role : .destructive ) {} FLXButton ( "Outline" , variant : .outline ) {} FLXButton ( "Secondary" , variant : .secondary ) {} FLXButton ( "Ghost" , variant : .ghost ) {} FLXButton ( "Link" , variant : .link ) {} } . padding ( FLXSpacing.xl ) } } Show more
Installation
Requires the design system foundation (tokens and theme).
CLI Manual
pnpm dlx shadcn@latest add @swiftui-flx/ios-button
Usage
FLXButton ( "Save" , variant : .primary ) { /* action */ }
Variants
Five variants, set via variant:.
FLXButton ( "Primary" , variant : .primary ) {} FLXButton ( "Outline" , variant : .outline ) {} FLXButton ( "Secondary" , variant : .secondary ) {} FLXButton ( "Ghost" , variant : .ghost ) {} FLXButton ( "Link" , variant : .link ) {}
Liquid Glass
FLXButton is for the content layer: forms, cards, and lists. For controls that float above content, use the native Button with Apple's glass styles and bring the theme in through .tint(_:). The system draws the glass and updates it with each OS release. Requires iOS 26.
Glass and Glass Prominent
Use .glass for most floating controls and .glassProminent for the primary action, which fills with the tint.
@Environment ( \.flxTheme ) private var theme HStack ( spacing : FLXSpacing.md ) { Button ( "Filters" , systemImage : "line.3.horizontal.decrease" ) {} . buttonStyle ( .glass ) Button ( "Add" , systemImage : "plus" ) {} . buttonStyle ( .glassProminent ) . tint ( theme.colors.tint ) }
Icon-only
Combine .labelStyle(.iconOnly) with .buttonBorderShape(.circle).
HStack ( spacing : FLXSpacing.md ) { Button ( "Share" , systemImage : "square.and.arrow.up" ) {} . buttonStyle ( .glass ) Button ( "Favorite" , systemImage : "heart" ) {} . buttonStyle ( .glass ) Button ( "Add" , systemImage : "plus" ) {} . buttonStyle ( .glassProminent ) . tint ( theme.colors.tint ) } . labelStyle ( .iconOnly ) . buttonBorderShape ( .circle ) . controlSize ( .large )
Glass sizes
Glass buttons follow .controlSize(_:), up to .extraLarge.
VStack ( spacing : FLXSpacing.md ) { Button ( "Small" ) {} . controlSize ( .small ) Button ( "Regular" ) {} Button ( "Large" ) {} . controlSize ( .large ) Button ( "Extra large" ) {} . controlSize ( .extraLarge ) } . buttonStyle ( .glass )
Over photos and video, use .glass(.clear). It's more transparent than .glass, so over bright media add a dark dimming layer to keep the symbols legible.
ZStack ( alignment : .bottom ) { LinearGradient ( colors : [.orange, .pink, .purple], startPoint : .topLeading, endPoint : .bottomTrailing ) HStack ( spacing : FLXSpacing.md ) { Button ( "Play" , systemImage : "play.fill" ) {} Button ( "Share" , systemImage : "square.and.arrow.up" ) {} } . labelStyle ( .iconOnly ) . buttonStyle ( . glass ( .clear )) . buttonBorderShape ( .circle ) . controlSize ( .large ) . padding ( FLXSpacing.lg ) } . frame ( width : 280 , height : 180 ) . clipShape ( . rect ( cornerRadius : 24 ))
In a toolbar, use a plain Button with no style: the system applies Liquid Glass to toolbar items, and items in the same ToolbarItemGroup share one background.
@Environment ( \.flxTheme ) private var theme NavigationStack { VStack ( spacing : FLXSpacing.md ) { FLXAvatar ( size : .large ) { FLXAvatarFallback ( "FM" ) FLXAvatarImage ( url : URL ( string : "https://github.com/felipemenezes098.png" )) } VStack ( spacing : FLXSpacing.xs ) { Text ( "Felipe Menezes" ) . flxFont ( .title3, weight : .semibold ) Text ( "Software Engineer" ) . flxFont ( .callout ) . foregroundStyle ( theme.colors.mutedForeground ) } } . frame ( maxWidth : . infinity , maxHeight : . infinity ) . navigationTitle ( "Profile" ) . navigationBarTitleDisplayMode ( .inline ) . toolbar { ToolbarItemGroup ( placement : .primaryAction ) { Button ( "Share" , systemImage : "square.and.arrow.up" ) {} Button ( "More" , systemImage : "ellipsis" ) {} } } }
Don't use Liquid Glass in the content layer, such as cards, lists, or forms. See Apple's Materials guidelines.
Destructive
Set via role:, like the native Button.
FLXButton ( "Destructive" , role : .destructive ) {}
Sizes
Set via .controlSize(_:), like native controls. For an icon-only button, use .labelStyle(.iconOnly).
FLXButton ( "Small" ) {} . controlSize ( .small ) FLXButton ( "Regular" ) {} FLXButton ( "Large" ) {} . controlSize ( .large ) FLXButton ( "Add" , systemImage : "plus" ) {} . labelStyle ( .iconOnly )
As Link
To open a URL, use SwiftUI's native Link and apply FLXButtonStyle. Link keeps link semantics for VoiceOver and opens the URL itself, so don't use FLXButton with openURL in its action.
Link ( "Open website" , destination : url ) . buttonStyle ( FLXButtonStyle ( variant : .primary ))
Custom styling
FLXButtonStyle conforms to SwiftUI's native ButtonStyle. Override rendering for a subtree with any ButtonStyle via .flxButtonStyle(_:):
struct FLXPillButtonStyle : ButtonStyle { func makeBody ( configuration : Configuration) -> some View { configuration.label . flxFont ( .body, weight : .medium ) . padding ( .horizontal, FLXSpacing.xl ) . padding ( .vertical, FLXSpacing.md ) . foregroundStyle ( .white ) . background ( .blue.gradient ) . clipShape ( Capsule ()) . opacity ( configuration.isPressed ? FLXOpacity.pressed : 1 ) } } HStack ( spacing : FLXSpacing.md ) { FLXButton ( "Pill" , variant : .primary ) {} FLXButton ( "Pill" , variant : .primary ) {} . flxButtonStyle ( FLXPillButtonStyle ()) } Show more
The override replaces FLXButtonStyle entirely, so variant: has no effect on buttons inside it. role: still reaches your style through configuration.role.
API Reference
init ( role : ButtonRole ? = nil , variant : FLXButtonVariant = .primary, action : @escaping () -> Void , @ ViewBuilder label : @escaping () -> Label ) init ( _ titleKey : LocalizedStringKey, role : ButtonRole ? = nil , variant : FLXButtonVariant = .primary, action : @escaping () -> Void ) init ( _ titleResource : LocalizedStringResource, role : ButtonRole ? = nil , variant : FLXButtonVariant = .primary, action : @escaping () -> Void ) init < S : StringProtocol > ( _ title : S, role : ButtonRole ? = nil , variant : FLXButtonVariant = .primary, action : @escaping () -> Void ) init ( _ titleKey : LocalizedStringKey, systemImage : String , role : ButtonRole ? = nil , variant : FLXButtonVariant = .primary, action : @escaping () -> Void ) init ( _ titleResource : LocalizedStringResource, systemImage : String , role : ButtonRole ? = nil , variant : FLXButtonVariant = .primary, action : @escaping () -> Void ) init < S : StringProtocol > ( _ title : S, systemImage : String , role : ButtonRole ? = nil , variant : FLXButtonVariant = .primary, action : @escaping () -> Void )
Variants
For more information about FLXButton props, see the Apple documentation .