suiss/ui · Component
Separator
A thin line that visually divides content, horizontally or vertically.
Separator is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
Separator wraps the separator primitive of the chosen base. It draws a 1px line in the border color: full width when horizontal, and stretched to the container's height when vertical.
Use it between groups of content or between inline items. Inside menus and selects, use the dedicated separator part of that component instead.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
- Install the following dependencies and add the
cnhelper:
- Copy and paste the following code into your project.
- Update the import paths to match your project setup.
Usage
Examples
Horizontal
The default horizontal orientation divides two stacked lines of text.
Vertical
Set orientation="vertical" inside a flex row to divide inline links. The line stretches to the row's height, so give the row a height.
Accessibility
- Renders with the
separatorrole and anaria-orientationthat matchesorientation.
API Reference
Separator
Draws the dividing line.
Also accepts the props of the primitive part it wraps.
orientation defaults to horizontal. The separator sets data-slot="separator", and the primitive's orientation attributes set its size.
Web preview
Separator is a View drawn as a one-pixel line. Horizontal separators fill the width of their container; vertical separators stretch to the height of a row.
Installation
- Install the following dependencies:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/separator.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/separator.tsx:
- Update the import paths to match your project setup.
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/separator.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Copy the theme files every view uses:
- Copy the source:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Examples
Horizontal
A horizontal separator between two lines of text.
Web preview
Vertical
A vertical separator between two items in a row.
Web preview
Accessibility
- The separator is decorative and hidden from VoiceOver and TalkBack.
API Reference
Separator
Draws the dividing line.
Also accepts the props of React.ComponentProps<typeof SeparatorPrimitive>.
Use the default horizontal orientation between stacked blocks, and orientation="vertical" between items in a row. Add spacing with className, such as my-4.
Separator
Draws the dividing line.
| Parameter | Type | Default |
|---|---|---|
_Â orientation | Axis | .horizontal |
Separator
Draws the dividing line.
| Parameter | Type | Default |
|---|---|---|
modifier | Modifier | Modifier |
orientation | Orientation | Orientation.Horizontal |