Dynamic Island
API reference

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.

PropTypeDefaultDescription
componentsRecord<K, DynamicIslandComponent<K>>RequiredState definitions, indexed by their keys.
valueKRequiredThe active key. It must exist in components.
initialAnimatedConfigAnimatedConfigUnsetInitial container target. When omitted, the container starts at the active state's target without an entrance animation.
classNamestringUnsetAdditional outer container classes.
styleCSSPropertiesUnsetInline outer container styles.
transitionTransitionSpringThe container transition. The default uses type: 'spring', damping: 25, and stiffness: 282.
contentPropsContentPropsUnsetOverrides 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.

PropertyTypeDescription
animatedConfigAnimatedConfigRequired Motion target, for example { width: 280, height: 120 }.
render(key: K) => ReactNodeRequired render function. Receives the active key.
classNamestringAdditional classes for this state's outer container.
styleCSSPropertiesInline container styles for this state.
transitionTransitionContainer transition overrides for this state.
contentPropsContentPropsContent wrapper overrides for this state.
Other motion propsMotionPropsState-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.

PropertyTypePurpose
classNamestringInner wrapper classes.
styleCSSPropertiesInner wrapper styles.
initialMotionProps['initial']Content entrance starting values.
animateMotionProps['animate']Content's visible target.
exitMotionProps['exit']Content's exit target.
transitionTransitionTransition 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

ExportDefinition
AnimatedConfigAn 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.
ContentPropsMotion and styling props for the inner wrapper.