Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions docs/6.x/docs/guides/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ In 5.x, each of these components multiplied `roundness` by a fixed number, and t

| Role | Default | 5.x multiplier | Components |
| ---------------- | ------- | -------------- | --------------------------------------------------- |
| `extraSmall` | 4 | 1 | `Menu`, `Snackbar`, `Tooltip` |
| `extraSmall` | 4 | 1 | `Snackbar`, `Tooltip` |
| `small` | 8 | 2 | `Chip` |
| `medium` | 12 | 3 | `Card` |
| `largeIncreased` | 20 | 5 | `SegmentedButtons` |
Expand Down Expand Up @@ -921,8 +921,14 @@ The `overlayAccessibilityLabel` prop was renamed to `dismissAccessibilityLabel`:
</Menu>
```

`Menu` and `Menu.Item` now follow the Material Design 3 menu specs. The surface is `surfaceContainerLow` instead of `theme.colors.elevation.level2`. The `elevation` prop is unchanged but now only sets the shadow; it no longer changes the fill color. Its corners are 16dp instead of 4dp. To change the fill, override `surfaceContainerLow` in your theme. Item titles use `labelLarge` instead of `bodyLarge`, and items have 4dp corners, or 12dp when `selected`.

New: `Menu` takes `colorScheme` (`standard` or `vibrant`), and `Menu.Item` takes `selected`, `supportingText` and `trailingSupportingText`.

On web, a menu now closes on the Escape key when it is pressed down, instead of when it is released. Back and Escape dismiss only the topmost overlay, so a menu opened from a `Modal` or `Dialog` closes first and leaves the modal open.

On Android, opening a menu now moves screen reader focus to its first enabled item, and closing it moves focus back to the anchor. With a hardware keyboard, the Up and Down arrow keys move between the enabled items and skip disabled ones. Moving keyboard focus into the menu when it opens also needs React Native's `enableImperativeFocus` feature flag, which is off by default; without it, TalkBack still works, but the keyboard focus stays where it was.

On Android, an open menu now also keeps the back press: it calls `onDismiss`, and the screen behind no longer goes back. Previously the press reached that screen as well. Without an `onDismiss`, the menu leaves the press to whatever is underneath, so pass one to close the menu on back.

### Searchbar
Expand Down Expand Up @@ -1685,11 +1691,7 @@ For `tonal`, toggle-on draws `secondary` with an `onSecondary` icon, and toggle-
<Card.Title
title="Card title"
right={(props) => (
<IconButton
icon="dots-vertical"
iconSize={props.size}
onPress={onPress}
/>
<IconButton icon="dots-vertical" iconSize={props.size} onPress={onPress} />
)}
/>
```
Expand Down
Binary file added docs/public/screenshots/menu-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/screenshots/menu-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/screenshots/menu-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/screenshots/menu-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/screenshots/menu-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/screenshots/menu-ios-bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/screenshots/menu-ios-closed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/screenshots/menu-ios-icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/screenshots/menu-ios-selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/screenshots/menu-ios-vibrant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/screenshots/menu-item.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion docs/src/data/screenshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ export const screenshots = {
'List.Section': 'screenshots/list-section.png',
Menu: {
'with icons': 'screenshots/menu-1.png',
'without icons': 'screenshots/menu-2.png',
'selected + supporting': 'screenshots/menu-2.png',
'vibrant scheme': 'screenshots/menu-3.png',
'bottom anchor': 'screenshots/menu-4.png',
},
'Menu.Item': 'screenshots/menu-item.png',
Modal: 'screenshots/modal.gif',
Expand Down
31 changes: 27 additions & 4 deletions docs/src/data/themeColors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,18 +294,41 @@ export const themeColors = {
},
},
Menu: {
'-': {
backgroundColor: 'theme.colors.elevation.level2',
standard: {
backgroundColor: 'theme.colors.surfaceContainerLow',
},
vibrant: {
backgroundColor: 'theme.colors.tertiaryContainer',
},
'selected item': {
backgroundColor: 'theme.colors.tertiaryContainer',
textColor: 'theme.colors.onTertiaryContainer',
},
},
'Menu.Item': {
default: {
textColor: 'theme.colors.onSurface',
iconColor: 'theme.colors.onSurfaceVariant',
supportingColor: 'theme.colors.onSurfaceVariant',
},
selected: {
backgroundColor: 'theme.colors.tertiaryContainer',
textColor: 'theme.colors.onTertiaryContainer',
iconColor: 'theme.colors.onTertiaryContainer',
},
disabled: {
textColor: 'theme.colors.onSurfaceDisabled',
iconColor: 'theme.colors.onSurfaceDisabled',
textColor: 'theme.colors.onSurface',
iconColor: 'theme.colors.onSurfaceVariant',
contentOpacity: 'theme.state.opacity.disabled (0.38)',
},
vibrant: {
textColor: 'theme.colors.onTertiaryContainer',
iconColor: 'theme.colors.onTertiaryContainer',
},
'vibrant selected': {
backgroundColor: 'theme.colors.tertiary',
textColor: 'theme.colors.onTertiary',
iconColor: 'theme.colors.onTertiary',
},
},
Modal: {
Expand Down
52 changes: 48 additions & 4 deletions example/src/Examples/MenuExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,57 @@ const MenuExample = () => {
anchorPosition="bottom"
anchor={
<Button mode="outlined" onPress={_toggleMenu('menu5')}>
Menu with anchor position bottom
Menu with selection + supporting text
</Button>
}
>
<Menu.Item onPress={() => {}} title="Item 1" />
<Menu.Item onPress={() => {}} title="Item 2" />
<Menu.Item onPress={() => {}} title="Item 3" />
<Menu.Item
leadingIcon="content-copy"
onPress={() => {}}
title="Copy"
trailingSupportingText="⌘C"
/>
<Menu.Item
leadingIcon="content-paste"
onPress={() => {}}
title="Paste"
supportingText="Insert clipboard"
selected
/>
<Menu.Item
leadingIcon="share-variant"
onPress={() => {}}
title="Share"
dense
/>
<Menu.Item onPress={() => {}} title="Delete" disabled />
</Menu>
</View>

<View style={styles.alignCenter}>
<Menu
visible={_getVisible('menu6')}
onDismiss={_toggleMenu('menu6')}
colorScheme="vibrant"
anchor={
<Button mode="outlined" onPress={_toggleMenu('menu6')}>
Vibrant color scheme
</Button>
}
>
<Menu.Item leadingIcon="star" onPress={() => {}} title="Featured" />
<Menu.Item
leadingIcon="heart"
onPress={() => {}}
title="Favorite"
selected
/>
<Menu.Item
leadingIcon="bell-off"
onPress={() => {}}
title="Muted"
disabled
/>
</Menu>
</View>

Expand Down
2 changes: 1 addition & 1 deletion src/components/FAB/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ const Menu = ({
);
};

Menu.displayName = 'Menu';
Menu.displayName = 'FAB.Menu';

const styles = StyleSheet.create({
container: {
Expand Down
Loading