---
title: Motion Highlight
description: Motion highlight component that displays the motion highlight effect.
author:
name: imskyleen
url: https://github.com/imskyleen
---
## Installation
## Usage
```tsx
Item 1
Item 2
Item 3
```
## Examples
### Tabs
### Tabs Hover
### Tabs Hover with Parent Mode
## Usage
### Uncontrolled Items
By default, child items will have the highlight effect. This will map the children elements and surround them with the `MotionHighlightItem` element.
```tsx
Item 1
Item 2
Item 3
```
### Controlled Items
Using the `controlledItems` props, you place your `MotionHighlightItem` wherever you like in the `MotionHighlight` component.
```tsx
Item 1
Item 2
Item 3
```
### Children Mode
By default, in `mode` with the value `children` the highlight is placed in the `MotionHighlightItem` component using Motion's `layoutId` technique. This technique should be preferred in most cases. However, in some cases, you may run into z-index problems, so it's best to use the `parent` mode to avoid visual bugs.
```tsx
Item 1
Item 2
Item 3
```
### Parent Mode
By using the `mode` property with the value `parent`, the `MotionHighlight` component will set the highlight to absolute in `MotionHighlight`. This may be useful in some cases to avoid the visual z-index bugs you can get with `mode` `children`.
```tsx
Item 1
Item 2
Item 3
```
### MotionHighlightItem asChild
#### Children Mode
```tsx
// With asChild
Item 1
Item 2
// Result
// Without asChild
Item 1
Item 2
// Result
```
#### Parent Mode
```tsx
// With asChild
Item 1
Item 2
// Result
{/* Highlight */}
Item 1
Item 2
// Without asChild
Item 1
Item 2
// Result
```
## Props
### MotionHighlight
void',
required: false,
},
transition: {
description: 'The transition of the motion highlight',
type: 'Transition',
required: false,
default: '{ type: "spring", stiffness: 200, damping: 25 }',
},
hover: {
description: 'Whether the motion highlight is on hover',
type: 'boolean',
required: false,
default: 'false',
},
enabled: {
description: 'Whether the motion highlight is enabled',
type: 'boolean',
required: false,
default: 'true',
},
disabled: {
description: 'Whether the motion highlight items is disabled',
type: 'boolean',
required: false,
default: 'false',
},
exitDelay: {
description: 'The delay of the exit of the motion highlight items',
type: 'number',
required: false,
default: '0.2',
},
mode: {
description: 'The mode of the motion highlight',
type: "'children' | 'parent'",
required: false,
default: 'children',
},
boundsOffset: {
description:
'The offset of the bounds of the motion highlight (only used when mode is "parent"). For example, you need to add an offset of the same size as the border when setting a border in containerClassName.',
type: 'Partial',
required: false,
default: 'undefined',
},
forceUpdateBounds: {
description:
'Whether to force update the bounds of the motion highlight items (only used when mode is "parent")',
type: 'boolean',
required: false,
default: 'undefined',
},
}}
/>
### MotionHighlightItem
## Credits
- Credits to [motion-primitives](https://motion-primitives.com/docs/animated-background) for the inspiration