Norsk Tipping Design System

Wizard

Install

yarn add @ntds/wizard

Import

import { WizardSheet } from '@ntds/wizard-sheet';

Props

PropTypeDefaultDescription
header?ReactNodeAdd a custom header (under the step bars) To use the standard header, use the `headerTitle` and `headerIcon` props
headerTitle?stringThe title of the header Use in combination with `headerIcon` For a custom header, use the `header` prop
headerIcon?ReactNodeUse in combination with `headerTitle`
twStepHeightstringSpecify the height of the steps All steps must have the same height for the wizard to work smoothly
noAutoPlay?booleanfalseWhether to autoplay the steps
autoplayDuration?numberThe duration of each step in milliseconds
stepsReactNode[]The steps of the wizard Can be any React component, but should typically be a simple component without scrollable content. Example: ```ts [ <div>Step 1</div>, <div>Step 2</div>, <div>Step 3</div>, ] ```
twStepColors?string[]Change the color of the sheet when changing steps Give a list of colors, one for each step
onChangeStep?(activeStep: number) => voidCallback when the active step changes @param activeStep
onCompleted?() => voidCallback when the wizard is completed
accessibleStepAnnouncement?(activeStep: number, totalSteps: number, autoplaying: boolean) => stringBuild a custom announcement for the active step A sane default is provided @param activeStep The active step @param totalSteps The total number of steps @param autoplaying Whether the wizard is currently autoplaying
id?stringPlain id
important?booleanIf the dialog is considered important (relative to its "siblings") If set to true: - Will be placed in front of any non-important sibling - Will be placed behind the first important sibling If set to false (default): - Will be placed behind all siblings
showbooleanShow/hide the modal
onClose() => voidCalling this will close the Sheet Typically, this will call a local set state in the application.
nested?ReactNodeNested Dialog/Sheet/PromptScreen components
initialFocus?MutableRefObject<HTMLElement>A ref to an element that should receive focus first. @see https://headlessui.com/react/dialog#focus-management
ntdsCustomContentClass?stringInternal className-tap-in for handling advanced heading configurations like in the responsible gaming modals (the dark haiti-"trapezium" ⏢)
closeGuard?booleanIf activated, the modal will prevent the user from dismissing the modal when swiping down "optimistically" and simply animate the Sheet up to its initial position. Example: Only allow dismissal when the customer have approved the customer agreement This is only relevant for when appearing as a sheet (and not as a modal).
UNSAFE_header?ReactNodeThis feature is considered unstable. Will most likely come into play when we look at filtering in insta games
footer?ReactNodePlaced after the content at the bottom. Will always be visible. Typically, this place is used for call-to-action buttons.
render?(props) => ReactNodeSame as the `footer`-prop, but as a render-prop with two bool params that can be used to differentiate: 1. isBottomSheet - whether the sheet is currently displayed as a bottom-sheet 2. isPointerDevice - whether the device uses a pointer device or not (media pointer: fine) * NOTE! If both the `children` & `render` is defined, the `render` will be used.
renderFooter?(isBottomSheet: boolean, isPointerDevice: boolean) => ReactNodeSame as the `footer`-prop, but as a render-prop with two bool params that can be used to differentiate: 1. isBottomSheet - whether the sheet is currently displayed as a bottom-sheet 2. isPointerDevice - whether the device uses a pointer device or not (media pointer: fine) * NOTE! If both the `footer` & `renderFooter` is defined, the `renderFooter` will be used.
absolutePositionedDecorator?(customClassNames: (className: string, options?: { roundedTop?: boolean; roundedBottom?: boolean; }) => string) => ReactNodeRenders provided element outside the inner wrapper, forgoing any margin and padding Default classNames being provided are: `absolute rounded-t-2xl rounded-b-2xl` The rounded classes will follow the Sheet styling both in "Sheet" (mobile) mode and "Dialog" mode (tablet/desktop) Example: ```ts absolutePositionedDecorator={customClassNames => ( <div className={ customClassNames('inset-x-0 bottom-0 bg-blue-sky flex justify-center items-center p-2') } > <HeartIcon /> </div> )} ``` If you don't want the rounded corner
twSheetHeight?stringLock the sheet height to a specific value Default is full (h-full). To make it grow with the content, use `h-auto`
twDesktopWidth?stringThe width of the sheet when displayed as a left/right drawer or a dialog (desktop and tablet) These settings have no effect on mobile (always full width) Default: `max-w-xl w-11/12`
twDialogHeightPlacement?stringThe height of the sheet when displayed as a dialog (desktop and tablet) Default: `inset-y-0 my-auto h-fit`
twColor?stringThe text and background color of the main area of the Sheet/Modal. Warning modal example: "bg-yellow-pastel"
twZIndex?stringOverride the z-index of the Sheet Default is z-1300
twFooterColor?string | string[]Color to use in the footer body. If not given, the twColor-value is used instead. Typically not needed. Warning modal example: empty.
UNSAFE_twHeaderColor?stringColor to use in the header
twBorderColor?string | string[]Border color to use around the header and footer Typically not needed. Warning modal example: empty.
twHandleColor?string | string[]The color of the Sheet "drag knob/handle" Only relevant if you change the background in twColor. Warning modal example: "bg-silver"
twPadding?SheetStyleOverridePadding to use for the main area of the Sheet/Modal.
twFooterPadding?SheetStyleOverrideThe padding to use for the footer.
childrenClassName?stringAdd class names to the immediate parent of the children Note: When `withContentStyling` is active, the CSS class for the content is also applied to the same element.
noSafeAreaInsetBottom?booleanOpt out of bottom safe-area inset spacing in sheet mode (mobile). By default, spacing is added to keep content and footer actions above native iOS bars. Default: false
withContentStyling?booleanIf set to true the content (`children`) will receive styling of basic elements like <p>, <li>, <h*>, ... Use this if you don't need full control of the elements mentioned above. You can also add className `ntds-content --compact` any place in your custom {children}. Note: you have to import '@ntds/core/css/src/ntds-content.css';
noHandle?booleanHides the handle (drag knob) in the side-sheet mode
twBackdropBlur?string | booleanDeactivate or customise the backdrop blur effect Default: backdrop-blur-sm @see https://tailwindcss.com/docs/blur#blurring-elements
dismissible?boolean | ((isBottomSheet: boolean, isPointerDevice: boolean) => boolean)If set to true, a close button will be shown in the side-sheet configuration or when the bottom sheet is (rarely) shown on desktop If you need to differentiate based on the sheet mode (bottom-sheet/side-sheet) or based on if the active device is a pointer device or not, you can provide a function instead of a boolean. This function will receive two bool params that can be used to differentiate: 1. isBottomSheet - whether the sheet is currently displayed as a bottom-sheet 2. isPointerDevice - whether the device uses a pointer device or not (media pointer: fine) - NOTE: Best effort: Better to fallback on an explicit close-button if has support for both touch and mouse Important: Remember to provide an accessibleCloseButtonLabel for the close button!
accessibleCloseButtonLabel?stringGive the close button a descriptive label for screen readers. Used when `dismissible` is set to `true`
desktopMode?SheetDesktopModeHow the sheet should behave on desktop (and tablet) Default: right
shrinkWhenInBackground?booleanIf set to true, the sheet will "shrink and lift" when a nested dialog/sheet/prompt is shown. Typically only used in combination with nested Sheets. Only affects the sheet-mode. Default: `false`
outsideElement?ReactNodeRender an element to be a part of the dialog semantics (including focus handling) but outside the fixed container Useful for edge cases where you need full control of the z-layer.
lang?stringLanguage property to specify the language of the content Default: no

On this page