Available from v1.0.0
Separator
Separator is a themed UIView subclass for dividing content with full-width, centered, or default styles.
Platform availability: iOS 17.0+
When to use:
- Use Separator when you need to visually divide content sections in lists, forms, or stacked layouts.
- Consider using spacing or padding alone when a visual divider line would add unnecessary visual noise.
It includes the following features:
- Three style options: full-width, centered, and default.
- Configurable inset for spacing control.
- Automatic color theming with design system colors.
Import
import BackbaseDesignSystem
Visual reference
|
|
|
|
|
|
|
|
API reference
Separator
Properties
|
Property |
Type |
Description |
|---|---|---|
|
color |
UIColor |
The color of the separator line |
|
inset |
CGFloat |
The inset is the leading and trailing inset based on the selected style |
|
style |
Style |
The style is the separator style from default, centered, or fullWidth |
Initializers
- init(style:inset:)
- Initializes and returns the separator view.
|
Parameter |
Type |
Description |
|---|---|---|
|
style |
Style |
The style of the separator. Defaults to .default |
|
inset |
CGFloat |
The inset of the separator when style is .centered. Defaults to 0 |
- init(frame:)
- Initializes and returns the separator view with a frame.
|
Parameter |
Type |
Description |
|---|---|---|
|
frame |
CGRect |
The frame rectangle for the view |
Separator.Style
An enumeration defining the style options for the separator.
|
Case |
Description |
|---|---|
|
fullWidth |
The separator fills its super view |
|
centered |
The leading and trailing are equal to the specified inset property |
|
default |
The leading is fixed to 16pt and trailing is 0pt |
Usage
Basic usage
Create a simple separator with default styling:
let separator = Separator()
view.addSubview(separator)
Full-width separator
Create a separator that spans the full width:
let separator = Separator(style: .fullWidth)
Centered separator with custom inset
Create a centered separator with custom inset:
let separator = Separator(style: .centered, inset: 24)
Custom color
Customize the separator color:
let separator = Separator()
separator.color = Theme.colors.border.default
Customization
Styling
The Separator automatically uses the design system's border color (Theme.colors.border.subtle).
Custom styles
Customize the separator appearance:
let separator = Separator(style: .centered, inset: DesignSystem.shared.spacer.lg)
separator.color = Theme.colors.border.default
Accessibility
This component is built with accessibility in mind. See the information below for supported behaviors and configuration options to ensure a fully accessible experience for all users.
Accessibility configuration
|
Property |
Type |
Description |
|---|---|---|
|
isAccessibilityElement |
Bool |
The isAccessibilityElement is false by default as the separator is decorative |
Best practices
- The Separator is a decorative element and does not require specific accessibility configuration.
- It is automatically excluded from the accessibility tree.
Dependencies
- External dependencies: None
- Internal dependencies: None
Design tokens
Component styling is applied automatically through the design system's theming infrastructure.
JSON tokens
This component uses semantic tokens only. See Semantic tokens below.
Semantic tokens
These tokens are accessed via the public DesignSystem.shared API.
|
Token |
API Reference |
Description |
|---|---|---|
|
Colors |
Theme.colors.border.default |
Separator line color |
|
Colors |
Theme.colors.border.subtle |
Default separator color |
|
Spacing |
DesignSystem.shared.spacer.lg |
Default inset spacing |
See also
- SummaryStackView - Component that may use separators between rows