--- localeCode: en-US order: 82 category: Show title: UserGuide icon: doc-userGuide brief: Used to guide new users through pages showNew: true --- ## Demos ### How to import ```jsx import import { UserGuide } from '@douyinfe/semi-ui'; ``` ### Basic Usage ```jsx live=true import React from 'react'; import { UserGuide, Button, Space, Tag, Switch } from '@douyinfe/semi-ui'; () => { const [visible, setVisible] = useState(false); const showDialog = () => { setVisible(true); }; return (


Default Tag { console.log('Current guide step', current); }} onNext={(current) => { console.log('Next guide step'); }} onPrev={(current) => { console.log('Previous guide step'); }} onFinish={() => { setVisible(false); console.log('Guide completed'); }} onSkip={() => { setVisible(false); console.log('Skip guide'); }} />
); }; ``` ### Theme `popup` bubble card mode provides two themes `default` and `primary`, set by the `theme` property. ```jsx live=true import React from 'react'; import { UserGuide, Button, Space, Tag, Switch } from '@douyinfe/semi-ui'; () => { const [visible, setVisible] = useState(false); const showDialog = () => { setVisible(true); }; return (


Default Tag { setVisible(false); console.log('引导完成'); }} onSkip={() => { setVisible(false); console.log('跳过引导'); }} />
); }; ``` ### Popup position `popup` bubble card mode provides 12 positions, optional values are `top`, `topLeft`, `topRight`, `left`, `leftTop`, `leftBottom`, `right`, `rightTop`, `rightBottom`, `bottom`, `bottomLeft`, `bottomRight`, and can be set by the `showArrow` property to display the arrow. ```jsx live=true import React from 'react'; import { UserGuide, Button, Space, Tag, Switch } from '@douyinfe/semi-ui'; () => { const [visible, setVisible] = useState(false); const showDialog = () => { setVisible(true); }; return (
{ setVisible(false); console.log('Guide completed'); }} onSkip={() => { setVisible(false); console.log('Skip guide'); }} />
); }; ``` ### Set the size of the highlight area Set by the `spotlightPadding` property. ```jsx live=true import React from 'react'; import { UserGuide, Button, Space, Tag, Switch } from '@douyinfe/semi-ui'; () => { const [visible, setVisible] = useState(false); const showDialog = () => { setVisible(true); }; return (


Default Tag { setVisible(false); console.log('Guide completed'); }} onSkip={() => { setVisible(false); console.log('Skip guide'); }} />
); }; ``` ### Customize the button Set by the `nextButtonProps` and `prevButtonProps` properties. ```jsx live=true import React from 'react'; import { UserGuide, Button, Space, Tag, Switch } from '@douyinfe/semi-ui'; () => { const [visible, setVisible] = useState(false); const showDialog = () => { setVisible(true); }; return (


Default Tag { setVisible(false); console.log('Guide completed'); }} onSkip={() => { setVisible(false); console.log('Skip guide'); }} />
); }; ``` ### Controlled Set by the `current` property. ```jsx live=true import React from 'react'; import { UserGuide, Button, Space, Tag, Switch } from '@douyinfe/semi-ui'; () => { const [visible, setVisible] = useState(false); const [current, setCurrent] = useState(0); const showDialog = () => { setVisible(true); }; return (


Default Tag { setCurrent(current); }} onFinish={() => { setVisible(false); setCurrent(0); console.log('Guide completed'); }} onSkip={() => { setVisible(false); setCurrent(0); console.log('Skip guide'); }} />
); }; ``` ### Modal guide Set by the `mode` property. ```jsx live=true import React from 'react'; import { UserGuide, Button, Space, Tag, Switch, Image, Typography } from '@douyinfe/semi-ui'; () => { const [visible, setVisible] = useState(false); const showDialog = () => { setVisible(true); }; return (
You can start from the published theme, or choose {Create Now} to create a new theme
, cover: , position: 'bottom', }, { title: 'High-available color palette', description: 'After selecting the main color, our color algorithm will generate a high-available color palette for you', cover: , position: 'bottom', }, { title: 'Customize freely', description: 'Start customizing your design system!', cover: , position: 'bottom', }, ]} onChange={(current) => { console.log('Current guide step', current); }} onNext={(current) => { console.log('Next guide step'); }} onPrev={(current) => { console.log('Previous guide step'); }} onFinish={() => { setVisible(false); console.log('Guide completed'); }} onSkip={() => { setVisible(false); console.log('Skip guide'); }} /> ); }; ``` ### No mask Set by the `mask` property. ```jsx live=true import React from 'react'; import { UserGuide, Button, Space, Tag, Switch, Image } from '@douyinfe/semi-ui'; () => { const [visible, setVisible] = useState(false); const showDialog = () => { setVisible(true); }; return (
{ setVisible(false); console.log('Guide completed'); }} onSkip={() => { setVisible(false); console.log('Skip guide'); }} />
); }; ``` ## API Reference --- | Properties | Instructions | Type | Default | Version | | --- | --- | --- | --- | --- | | className | Custom class name | string | - | | | current | Current step index | number | 0 | | | finishText | Text of the last step completion button | string | '完成' | | | mask | Whether to display the mask | boolean | true | | | mode | Guide mode, optional values: `popup` (bubble card) or `modal` (modal) | string | popup | | | nextButtonProps | The properties of the next button | ButtonProps | {} | | | onChange | Callback when the step changes | function(current: number) | () => void | | | onFinish | Callback when all steps are completed | function() | () => void | | | onNext | Callback when the next button is clicked | function(current: number) | () => void | | | onPrev | Callback when the previous button is clicked | function(current: number) | () => void | | | onSkip | Callback when the skip button is clicked | function() | () => void | | | position | The position of the pop-up layer relative to the target element, optional values: `top`, `topLeft`, `topRight`, `left`, `leftTop`, `leftBottom`, `right`, `rightTop`, `rightBottom`, `bottom`, `bottomLeft`, `bottomRight` | string | bottom | | | prevButtonProps | The properties of the previous button | ButtonProps | {} | | | showPrevButton | Whether to display the previous button | boolean | true | | | showSkipButton | Whether to display the skip button | boolean | true | | | spotlightPadding | The inner padding of the highlight area, in pixels | number | - | | | steps | Guide step configuration, required | StepItem[] | [] | | | style | Custom style | React.CSSProperties | - | | | theme | Theme style, optional values: `default` or `primary` | string | default | | | visible | Whether to display the guide | boolean | false | | | getPopupContainer | Specify the parent DOM, the pop-up layer will be rendered to the DOM | () => HTMLElement | - | | | zIndex | Pop-up layer level | number | 1030 | | ### Steps.Step | Properties | Instructions | Type | Default | Version | | --- | --- | --- | --- | --- | | className | Custom class name | string | - | | | cover | The cover image of the step | ReactNode | - | | | target | The target element, the highlight area will focus on this element | (() => Element) \| Element | - | | | title | Step title | string \| ReactNode | - | | | description | Step description | ReactNode | - | | | mask | Whether to display the mask of this step, it will override the global configuration | boolean | - | | | showArrow | Whether to display the arrow (only valid when mode=`popup`) | boolean | true | | | spotlightPadding | The inner padding of the highlight area of this step, it will override the global configuration | number | - | | | theme | The theme of this step, it will override the global configuration | `default` \| `primary` | - | | | position | The position of the pop-up layer of this step, it will override the global configuration | Position | - | | ## Design Tokens