diff --git a/docs/6.x/docs/guides/migration.md b/docs/6.x/docs/guides/migration.md
index 155a18f11d..f7b449ddc1 100644
--- a/docs/6.x/docs/guides/migration.md
+++ b/docs/6.x/docs/guides/migration.md
@@ -1012,6 +1012,71 @@ The misspelled `traileringIcon` props have been renamed:
/>
```
+### Divider
+
+| v5 | v6 |
+| --- | --- |
+| `leftInset` | `startInset` |
+| `bold` | removed, dividers are 1dp thick by default |
+| - | `orientation="vertical"` |
+
+#### Thickness
+
+Dividers are 1dp thick now, which is what the Material Design 3 spec asks for. In v5 the default was `StyleSheet.hairlineWidth`, thinner than 1dp on most screens, and `bold` was the only way to get a full 1dp line. The `bold` prop is gone.
+
+```diff
+-
++
+```
+
+If you want the hairline back, set it in `style`:
+
+```diff
+-
++
+```
+
+#### Inset
+
+`leftInset` set `marginLeft`, so in RTL the inset stayed on the left instead of moving to the leading edge. Use `startInset` instead. It insets the leading edge and follows the writing direction.
+
+```diff
+-
++
+```
+
+`horizontalInset` works the same as before.
+
+#### Orientation
+
+Dividers can be vertical now. A vertical divider is 1dp wide and stretches to the height of its parent, so the parent has to lay its children out in a row.
+
+```tsx
+
+ Lemon
+
+ Mango
+
+```
+
+Insets follow the orientation. On a vertical divider, `startInset` insets the top edge, and `horizontalInset` insets the top and bottom edges.
+
+#### Accessibility
+
+Dividers are decorative, so screen readers skip them and they stay out of the focus order. If a divider means something on its own, opt back in:
+
+```diff
+-
++
+```
+
+This also affects tests: `aria-hidden` excludes the divider from `getByTestId` and similar queries by default. Pass `{ includeHiddenElements: true }` to the query, or opt the divider into the accessibility tree as shown above.
+
+```diff
+- getByTestId('divider')
++ getByTestId('divider', { includeHiddenElements: true })
+```
+
### Chip
The close button (`onClose`) now fills the trailing 34dp column reserved for it, instead of only the 26x18 area around its icon, and its touch target extends to 48dp in height. Taps in that column that used to activate the chip's `onPress` now activate `onClose`.
diff --git a/example/src/Examples/DividerExample.tsx b/example/src/Examples/DividerExample.tsx
index 77df26a85a..a4adb2634b 100644
--- a/example/src/Examples/DividerExample.tsx
+++ b/example/src/Examples/DividerExample.tsx
@@ -1,28 +1,67 @@
-import { FlatList } from 'react-native';
+import * as React from 'react';
+import { StyleSheet, View } from 'react-native';
-import { Divider, List, useTheme } from 'react-native-paper';
+import { Divider, List, Text } from 'react-native-paper';
import ScreenWrapper from '../ScreenWrapper';
-const items = ['Apple', 'Banana', 'Coconut', 'Lemon', 'Mango', 'Peach'];
+const items = ['Apple', 'Banana', 'Coconut'];
const DividerExample = () => {
- const { colors } = useTheme();
-
return (
-
- }
- keyExtractor={(item) => item}
- ItemSeparatorComponent={Divider}
- data={items}
- alwaysBounceVertical={false}
- />
+
+
+ {items.map((item) => (
+
+
+
+
+ ))}
+
+
+ {items.map((item) => (
+
+
+
+
+ ))}
+
+
+ {items.map((item) => (
+
+
+
+
+ ))}
+
+
+
+ {items.map((item, index) => (
+
+ {index > 0 && }
+
+ {item}
+
+
+ ))}
+
+
);
};
DividerExample.title = 'Divider';
+const styles = StyleSheet.create({
+ row: {
+ flexDirection: 'row',
+ marginHorizontal: 16,
+ },
+ column: {
+ flex: 1,
+ paddingVertical: 24,
+ textAlign: 'center',
+ },
+});
+
export default DividerExample;
diff --git a/example/src/Examples/FABExample.tsx b/example/src/Examples/FABExample.tsx
index a7ed4ea2a0..237fe47012 100644
--- a/example/src/Examples/FABExample.tsx
+++ b/example/src/Examples/FABExample.tsx
@@ -161,7 +161,7 @@ const FABExample = () => {
)}
onPress={() => setShowFab((v) => !v)}
/>
-
+
, 'children'> & {
/**
- * @renamed Renamed from 'inset' to 'leftInset` in v5.x
- * Whether divider has a left inset.
+ * Orientation of the divider. A vertical divider stretches to the height of
+ * its parent, so the parent has to lay its children out in a row.
*/
- leftInset?: boolean;
+ orientation?: 'horizontal' | 'vertical';
/**
- * @supported Available in v5.x with theme version 3
- * Whether divider has a horizontal inset on both sides.
+ * Whether the divider is inset from the leading edge, which is the left edge
+ * in LTR and the right edge in RTL. On a vertical divider it's the top edge.
*/
- horizontalInset?: boolean;
+ startInset?: boolean;
/**
- * @supported Available in v5.x with theme version 3
- * Whether divider should be bolded.
+ * Whether the divider is inset from both edges: left and right on a
+ * horizontal divider, top and bottom on a vertical one.
*/
- bold?: boolean;
+ horizontalInset?: boolean;
style?: StyleProp;
/**
* @optional
@@ -31,6 +34,10 @@ export type Props = Omit, 'children'> & {
/**
* A divider is a thin, lightweight separator that groups content in lists and page layouts.
*
+ * Dividers are decorative, so screen readers skip them. If a divider means
+ * something on its own, pass `accessible`, `aria-hidden={false}` and
+ * `role="separator"`.
+ *
* ## Usage
* ```js
* import * as React from 'react';
@@ -50,25 +57,28 @@ export type Props = Omit, 'children'> & {
* ```
*/
const Divider = ({
- leftInset,
+ orientation = 'horizontal',
+ startInset = false,
horizontalInset = false,
style,
theme: themeOverrides,
- bold = false,
...rest
}: Props) => {
const theme = useInternalTheme(themeOverrides);
- const dividerColor = theme.colors.outlineVariant;
+ const isVertical = orientation === 'vertical';
return (
@@ -76,15 +86,26 @@ const Divider = ({
};
const styles = StyleSheet.create({
- v3LeftInset: {
- marginLeft: 16,
+ horizontal: {
+ height: THICKNESS,
+ },
+ vertical: {
+ width: THICKNESS,
+ alignSelf: 'stretch',
+ },
+ startInset: {
+ marginStart: INSET,
},
horizontalInset: {
- marginLeft: 16,
- marginRight: 16,
+ marginStart: INSET,
+ marginEnd: INSET,
+ },
+ verticalStartInset: {
+ marginTop: INSET,
},
- bold: {
- height: 1,
+ verticalInset: {
+ marginTop: INSET,
+ marginBottom: INSET,
},
});
diff --git a/src/components/Drawer/DrawerSection.tsx b/src/components/Drawer/DrawerSection.tsx
index feff7d083a..14ab773c1a 100644
--- a/src/components/Drawer/DrawerSection.tsx
+++ b/src/components/Drawer/DrawerSection.tsx
@@ -92,7 +92,7 @@ const DrawerSection = ({
)}
{children}
{showDivider && (
-
+
)}
);
diff --git a/src/components/Searchbar.tsx b/src/components/Searchbar.tsx
index f1f6adbbfd..33f10b7f89 100644
--- a/src/components/Searchbar.tsx
+++ b/src/components/Searchbar.tsx
@@ -348,7 +348,6 @@ const Searchbar = ({
right?.({ color: textColor, style: styles.rightStyle, testID })}
{!isBarMode && showDivider && (
{
+ const tree = (await render()).toJSON();
+
+ expect(tree).toMatchSnapshot();
+});
+
+it('renders vertical divider', async () => {
+ const tree = (await render()).toJSON();
+
+ expect(tree).toMatchSnapshot();
+});
+
+it('renders 1dp thick horizontal line by default', async () => {
+ await render();
+
+ expect(screen.getByTestId('divider', hidden)).toHaveStyle({
+ height: 1,
+ backgroundColor: LightTheme.colors.outlineVariant,
+ });
+});
+
+it('renders 1dp thick line stretched to the parent when vertical', async () => {
+ await render();
+
+ expect(screen.getByTestId('divider', hidden)).toHaveStyle({
+ width: 1,
+ alignSelf: 'stretch',
+ backgroundColor: LightTheme.colors.outlineVariant,
+ });
+ expect(screen.getByTestId('divider', hidden)).not.toHaveStyle({ height: 1 });
+});
+
+it('insets the start edge in a writing direction aware way', async () => {
+ await render();
+
+ const divider = screen.getByTestId('divider', hidden);
+
+ expect(divider).toHaveStyle({ marginStart: 16 });
+ expect(divider).not.toHaveStyle({ marginLeft: 16 });
+});
+
+it('insets both edges', async () => {
+ await render();
+
+ const divider = screen.getByTestId('divider', hidden);
+
+ expect(divider).toHaveStyle({ marginStart: 16, marginEnd: 16 });
+ expect(divider).not.toHaveStyle({ marginLeft: 16 });
+ expect(divider).not.toHaveStyle({ marginRight: 16 });
+});
+
+it('insets the leading end of a vertical divider', async () => {
+ await render();
+
+ const divider = screen.getByTestId('divider', hidden);
+
+ expect(divider).toHaveStyle({ marginTop: 16 });
+ expect(divider).not.toHaveStyle({ marginStart: 16 });
+});
+
+it('insets both ends of a vertical divider', async () => {
+ await render(
+
+ );
+
+ expect(screen.getByTestId('divider', hidden)).toHaveStyle({
+ marginTop: 16,
+ marginBottom: 16,
+ });
+});
+
+it('applies custom styles over the defaults', async () => {
+ await render();
+
+ expect(screen.getByTestId('divider', hidden)).toHaveStyle({ height: 4 });
+});
+
+it('stays out of the accessibility tree', async () => {
+ await render();
+
+ expect(screen.queryByTestId('divider')).toBeNull();
+ expect(screen.getByTestId('divider', hidden)).toHaveProp('aria-hidden', true);
+});
+
+it('can be exposed as a separator', async () => {
+ await render();
+
+ expect(screen.getByRole('separator')).toBeOnTheScreen();
+});
diff --git a/src/components/__tests__/Drawer/__snapshots__/DrawerSection.test.tsx.snap b/src/components/__tests__/Drawer/__snapshots__/DrawerSection.test.tsx.snap
index 9333709dfe..39d19756bd 100644
--- a/src/components/__tests__/Drawer/__snapshots__/DrawerSection.test.tsx.snap
+++ b/src/components/__tests__/Drawer/__snapshots__/DrawerSection.test.tsx.snap
@@ -13,19 +13,19 @@ exports[`DrawerSection renders properly 1`] = `
>
+`;
+
+exports[`renders vertical divider 1`] = `
+
+`;
diff --git a/src/components/__tests__/__snapshots__/Searchbar.test.tsx.snap b/src/components/__tests__/__snapshots__/Searchbar.test.tsx.snap
index a8d788e309..9bf1f8569a 100644
--- a/src/components/__tests__/__snapshots__/Searchbar.test.tsx.snap
+++ b/src/components/__tests__/__snapshots__/Searchbar.test.tsx.snap
@@ -820,17 +820,17 @@ exports[`renders searchbar in "view" mode 1`] = `