Tour Dialog
A tour dialog is used convey benefits or instructions for a new features.
Theming
The TourDialog
component is a multipart component. The styling needs to be
applied to each part specifically.
To learn more about styling multipart components, visit the Chakra UI Component Style page.
Anatomy
container
inner
main
Theming utilities
createMultiStyleConfigHelpers
: a function that returns a set of utilities for creating style configs for a multipart component (definePartsStyle
anddefineMultiStyleConfig
).definePartsStyle
: a function used to create multipart style objects.defineMultiStyleConfig
: a function used to define the style configuration for a multipart component.
import { tourDialogAnatomy } from '@saas-ui/theme/anatomy'import { createMultiStyleConfigHelpers } from '@chakra-ui/react'const { definePartsStyle, defineMultiStyleConfig } =createMultiStyleConfigHelpers(tourDialogAnatomy.keys)
Customizing the default theme
import { tourDialogAnatomy } from '@saas-ui/theme/anatomy'import { createMultiStyleConfigHelpers } from '@chakra-ui/react'const { definePartsStyle, defineMultiStyleConfig } =createMultiStyleConfigHelpers(tourDialogAnatomy.keys)const baseStyle = definePartsStyle({// define the part you're going to stylecontainer: {bg: 'red.200', // change the backgroundColor of the container},})export const tourDialogTheme = defineMultiStyleConfig({ baseStyle })
After customizing the app shell theme, we can import it in our theme file and
add it in the components
property:
import { extendTheme } from '@chakra-ui/react'import { tourDialogAnatomy } from './components/tour-dialog'export const theme = extendTheme({components: { SuiTourDialog: tourDialogAnatomy },})
Saas UI components are prefixed with
Sui
to avoid conflicts with Chakra UI. This is a crucial step to make sure that any changes that we make to the app shell theme are applied.
Adding a custom size
Let's assume we want to include an extra large app shell icon size. Here's how we can do that:
import { tourDialogAnatomy } from '@saas-ui/theme/anatomy'import { createMultiStyleConfigHelpers, defineStyle } from '@chakra-ui/react'const { definePartsStyle, defineMultiStyleConfig } =createMultiStyleConfigHelpers(tourDialogAnatomy.keys)const xl = definePartsStyle({container: {height: '1000px'}})const sizes = {xl,}export const app shellTheme = defineMultiStyleConfig({ sizes })// Now we can use the new `xl` size<TourDialog size="xl"> ... </TourDialog>
Every time you're adding anything new to the theme, you'd need to run the CLI command to get proper autocomplete in your IDE. You can learn more about the CLI tool here.
Adding a custom variant
Let's assume we want to include a custom pill variant. Here's how we can do that:
import { tourDialogAnatomy } from '@saas-ui/theme/anatomy'import { createMultiStyleConfigHelpers, defineStyle } from '@chakra-ui/react'const { definePartsStyle, defineMultiStyleConfig } =createMultiStyleConfigHelpers(tourDialogAnatomy.keys)const custom = definePartsStyle({container: {border: '1px solid',borderColor: 'gray.200',background: 'gray.50',borderRadius: 'full',// Let's also provide dark mode alternatives_dark: {borderColor: 'gray.600',background: 'gray.800',},},main: {border: '1px solid',borderColor: 'gray.200',background: 'gray.200',color: 'gray.500',_dark: {borderColor: 'gray.600',background: 'gray.600',color: 'gray.400',},},})export const tourDialogTheme = defineMultiStyleConfig({variants: { custom },})// Now we can use the new `custom` variant<TourDialog variant="custom"> ... </TourDialog>
Changing the default properties
Let's assume we want to change the default size and variant of every app shell in our app. Here's how we can do that:
import { tourDialogAnatomy } from '@saas-ui/theme/anatomy'import { createMultiStyleConfigHelpers, defineStyle } from '@chakra-ui/react'const { defineMultiStyleConfig } = createMultiStyleConfigHelpers(tourDialogAnatomy.keys,)export const tourDialogTheme = defineMultiStyleConfig({defaultProps: {variant: 'custom',},})// This saves you time, instead of manually setting the size and// variant every time you use an app shell:<TourDialog variant="custom"> ... </TourDialog>
Was this helpful?