- Implementation
- DrillDown Props
- DrillDown.Header Props
- DrillDown.Content Props
- useDrillDown hook
Common Examples
Use as children of Dialog, Drawer, or Page.Panel
Any number of DrillDown components can be added as children of the Dialog, Drawer, or Page.Panel component. When a DrillDown is visible, it will cover the entire contents of the Dialog or Drawer.Each
DrillDown requires a unique indexDrillDown sibling components are identified by their index prop. Numbers used for the index prop are zero-based, and calling next or clicking the DrillDown.NextButton will display the next index in numerical order.Uncontrolled usage
SetdefaultDrillDownIndex on the host (Dialog, Drawer, or Page.Panel) to choose which DrillDown screen the first next() opens from a closed stack. The prop type is number and defaults to 0. The host starts with no active screen. Closing the host restores this index.Use defaultDrillDownIndex when that first next() should not open index 0—for example, skipping an intro screen.With
defaultDrillDownIndex={1}, the first next opens index 1. Index 0 stays in the tree for later setIndex(0) jumps but is not reached by Next/Prev alone—back from the start index closes the flow.Using DrillDown.NextButton and DrillDown.PrevButton
The DrillDown can be used with uncontrolled state by using the DrillDown.NextButton to move forward to each DrillDown index in ascending numerical order. The first next call opens defaultDrillDownIndex on the host. The DrillDown.PrevButton will similarly move backward in descending numerical order, and will close the DrillDown if there is no previous screen.Controlled usage
Controlled navigation still usesdefaultDrillDownIndex on the host for the first next() from a closed stack and for restore-on-close. Spread useDrillDown().drillDownProps onto the same host, then call next, back, or setIndex for programmatic moves. Omit the prop to restore to 0 (shown below), or pass a non-zero value when the first next() should open a later screen.Using the useDrillDown hook
The useDrillDown hook returns a next and back function to allow for programmatically navigating between DrillDown components in numerical index order. (The hook also returns a setIndex function to allow navigating to arbitrary index values.)To allow this hook to work, the drillDownProps return value also needs to be spread onto the parent component.Closing from within a DrillDown
By default, the DrillDown.Header does not display a close button. To display a close button in the DrillDown.Header, add an onClose handler to the DrillDown.Header actions
To add an overflow menu to theDrillDown.Header, pass an actions array. The menu appears to the left of the close button, or on its own when the DrillDown has no onClose.Actions belong to the screen that defines them. A DrillDown does not inherit the actions from Drawer.Header, so pass the commands that apply to each screen.