DynamicIsland
Props, state configuration, content overrides, and exported types.
Import
import DynamicIsland, {
ContentWrapper,
type AnimatedConfig,
type ContentProps,
type DynamicIslandComponent,
type DynamicIslandProps,
} from "ob-react-dynamic-island";DynamicIsland is the default export. Its generic parameter describes the valid string keys in your state map.
type State = "idle" | "expanded";
const components: Record<State, DynamicIslandComponent<State>> = {
idle: {
animatedConfig: { width: 120, height: 36, borderRadius: 24 },
render: () => <span>Ready</span>,
},
expanded: {
animatedConfig: { width: 280, height: 120, borderRadius: 32 },
render: () => <span>Everything is up to date.</span>,
},
};See your first island for a runnable example including state and styles.
Container props
DynamicIslandProps<K> extends Motion's MotionProps, excluding children, layout, initial, and animate. The component manages those four properties internally.
| Prop | Type | Default | Description |
|---|---|---|---|
components | Record<K, DynamicIslandComponent<K>> | Required | State definitions, indexed by their keys. |
value | K | Required | The active key. It must exist in components. |
initialAnimatedConfig | AnimatedConfig | Unset | Initial container target. When omitted, the container starts at the active state's target without an entrance animation. |
className | string | Unset | Additional outer container classes. |
style | CSSProperties | Unset | Inline outer container styles. |
transition | Transition | Spring | The container transition. The default uses type: 'spring', damping: 25, and stiffness: 282. |
contentProps | ContentProps | Unset | Overrides for the content wrapper. |
Other supported MotionProps, such as whileHover and onAnimationComplete, are forwarded to the outer Motion element. This type is based on MotionProps, not the full set of HTML div attributes.
The container renders with layout animation enabled, inside a LayoutGroup. It includes the base utility classes relative overflow-hidden; see installation for styling setup.
State configuration
Each DynamicIslandComponent<K> entry defines the target and content for one state.
| Property | Type | Description |
|---|---|---|
animatedConfig | AnimatedConfig | Required Motion target, for example { width: 280, height: 120 }. |
render | (key: K) => ReactNode | Required render function. Receives the active key. |
className | string | Additional classes for this state's outer container. |
style | CSSProperties | Inline container styles for this state. |
transition | Transition | Container transition overrides for this state. |
contentProps | ContentProps | Content wrapper overrides for this state. |
| Other motion props | MotionProps | State-specific motion options forwarded to the container. |
Override order
State-level props take precedence over top-level props. transition, contentProps, and other forwarded props are deep-merged, so a state can change one nested option while preserving the rest.
Container class names are combined with clsx and tailwind-merge, with the state classes applied last.
const components: Record<"idle" | "expanded", DynamicIslandComponent> = {
idle: {
animatedConfig: { width: 120, height: 36, borderRadius: 24 },
render: () => <span>Ready</span>,
},
expanded: {
animatedConfig: { width: 280, height: 120, borderRadius: 32 },
transition: { damping: 30 },
contentProps: { style: { padding: 20 } },
render: () => <span>Changes saved.</span>,
},
};
// In the expanded state, damping becomes 30 and stiffness remains 282.
<DynamicIsland value="expanded" components={components} />;ContentProps
ContentProps extends MotionProps, excluding children and key, and adds className and style.
| Property | Type | Purpose |
|---|---|---|
className | string | Inner wrapper classes. |
style | CSSProperties | Inner wrapper styles. |
initial | MotionProps['initial'] | Content entrance starting values. |
animate | MotionProps['animate'] | Content's visible target. |
exit | MotionProps['exit'] | Content's exit target. |
transition | Transition | Transition for the content, independently of the container. |
The wrapper defaults to layout: 'position', enters from opacity 0 and a 4px blur, and becomes fully opaque with no blur. It exits to opacity 0 and a 4px blur over 0.15 seconds. The blur is removed when the user requests reduced motion.
The internal AnimatePresence uses mode="popLayout" and initial={false}. Content is keyed by value, so its enter and exit transitions run when the active key changes, rather than on the first render.
Content overrides are deep-merged
Set the properties you want to replace explicitly. For example, setting initial: { y: 8 } keeps the default opacity and blur values. Set filter: 'none' as well if you want to remove the blur.
ContentWrapper
ContentWrapper is also available as a named export. It is a forwardRef component that renders a Motion div with the same default content animation and accepts children, a class name, and Motion props.
The island already creates a ContentWrapper around your render result. You only need the export when reusing this content treatment elsewhere. Outside the island, provide your own AnimatePresence if you need an exit transition.
Exported types
| Export | Definition |
|---|---|
AnimatedConfig | An alias of Motion's Target. |
DynamicIslandProps<K> | Container props, with K extends string and a default of string. |
DynamicIslandComponent<K> | A single state's configuration. |
ContentProps | Motion and styling props for the inner wrapper. |