React Beacon Hint Documentation

website·Indexed 29 days ago

https://react-beacon-hint-doc.vercel.app/

A React library for creating beacons and hints to guide users through an interface. It includes components such as Hint, Beacon (FillBeacon, OutlineBeacon), Popover, and Floating, providing tools for installation, usage, and API integration.

Tokens
2.9K
Snippets
23
Records
36
Agent score
74%

What's inside React Beacon Hint

  1. Use the Hint component to create a guided popover

    The Hint component is used to display a popover when a user hovers over or clicks a beacon, serving as a guide for application users. It wraps a trigger element (such as a Button) and takes a popover string for the message and a hit count to track or trigger the hint.
    <Hint popover="Hello World" hit={1}>
    	<Button>Hover Me</Button>
    </Hint>
  2. Install react-beacon-hint

    Install the react-beacon-hint package and its required peer dependency @floating-ui/react (which handles anchor positioning) using your preferred package manager.
    # Install the main library
    npm install react-beacon-hint
    
    # Install the required dependency
    npm install @floating-ui/react
  3. Test React Beacon Hint using the online playground

    You can test React Beacon Hint or report bugs without local installation by using the official CodeSandbox playground. This provides a browser-based development environment to experiment with the library immediately.
    Visit the official playground on CodeSandbox: 
    https://codesandbox.io/p/github/moh3n9595/react-beacon-hint/main
  4. Customize the Hint beacon and popover appearance

    Configure the visual elements of the hint:

    • beacon ("fill" | "outline" | ReactElement, default: "outline"): The style of the beacon indicator.
    • popover (string | ReactElement): The content displayed when the beacon is active.
    • beaconProps (Object): Configuration for the floating beacon. Includes autoOffset (boolean, default: true).
    • popoverProps (Object): Configuration for the floating popover. Default includes an enabled arrow with specific dimensions and disabled hover props.
  5. Implement a basic popover hint with React Beacon Hint

    To create a guided hint popover, wrap the target element (e.g., a button) with the Hint component and provide the text to display in the popover prop. You must import the accompanying CSS styles for the hint to render correctly.
    import {Hint} from 'react-beacon-hint';
    import 'react-beacon-hint/styles.css';
    
    const Component = () => {
    	return (
    		<Hint popover='Yay! I appeared!'>
    			<button>Click The Hint</button>
    		</Hint>
    	);
    };